I have a Stream in which there is uploaded text file. The file can have any encoding - ANSI, UTF8 without BOM, UTF8 with BOM. The file has characters which are specific for some languages - e.g. ąę. I need to save all files as UTF8 BOM files on the server side, but I can't force all users to upload me UTF8 BOM files. Special characters in saved file must maintain correct - so ąę. How can I do this?  I have:          using (Stream inputStream = file.InputStream)         {             byte[] bytes = ReadFully2(inputStream);             string utf8string = .....what here?.....             System.IO.File.WriteAllText("", utf8string, System.Text.Encoding.UTF8);         }   public static byte[] ReadFully2(Stream input) {     input.Position = 0;     using (MemoryStream ms = new MemoryStream())     {         input.CopyTo(ms);         return ms.ToArray();     } }
In our application, we receive text files (.txt, .csv, etc.) from diverse sources. When reading, these files sometimes contain garbage, because the files where created in a different/unknown codepage.  Is there a way to (automatically) detect the codepage of a text file?   The detectEncodingFromByteOrderMarks, on the StreamReader constructor, works for UTF8  and other unicode marked files, but I'm looking for a way to detect code pages, like ibm850, windows1252.     Thanks for your answers, this is what I've done.  The files we receive are from end-users, they do not have a clue about codepages. The receivers are also end-users, by now this is what they know about codepages: Codepages exist, and are annoying.  Solution:    Open the received file in Notepad, look at a garbled piece of text. If somebody is called François or something, with your human intelligence you can guess this. I've created a small app that the user can use to open the file with, and enter a text that user knows it will appear in the file, when the correct codepage is used.  Loop through all codepages, and display the ones that give a solution with the user provided text.  If more as one codepage pops up, ask the user to specify more text.
Is There Any Way to get the template Name By full URL for example  If the full url is  www.example.com/hello-world   I need a function that return the template name (page.php)  I know that WordPress matches every url with regular expression to determine the query and decide which template to include.  That's exactly what I need, a built in or (custom made) function that takes the URL and returns back the corresponding template I have a Non Root User abc and want to give the user sudo rights only to restart, start or stop - mysqld service. i.e sudo service mysqld restart. How can I do it so?     I would like to do the same to usergroup too!! Schengen Visa Application: what are some helpful tips for preparing? Probability of student passing an exam There're $25$ tests, each with $2$ questions. There're total of $50$ different questions (the questions do not repeat). The student knows the answer of $44$ questions. To pass the exam, the student needs to correctly answer both questions on the first test he drew, or answer $1$ question from the test he drew first, and $1$ question from the test he drew second. (meaning he draws twice if he answers a question incorrectly on his first try)  What is the probability that the student will pass the exam?  I have never faced a problem like this one so any help is appreciated. I was thinking about approaching it "manually" with some applied combinatorics but I feel like there's a much easier way that I am not familiar with. I occasionally update my kernel from this web site    I have been always downloading 3 deb files for installing  linux header all, linux image and linux headers. I noticed one more deb file recently for 64 bit kernel called Linux-image-extra.  I would like to know what does kernel file Linux-image-extra do and should I also install it? How many square meters "twenty feet square" is? One would assume it to be about 2 square meters, but this is obviously not the case. In fact, I'm reading Illium by Dan Simmons. A quote follows:     Much like the room they had faxed into, this space was windowless and about twenty feet square. But unlike the other room, this one was warm, lighted, and free of snow or ice. And unlike the other room, this one was almost filled with an oval metal machine about fifteen feet long.   By this description, "twenty feet square" seems to mean 20x20 feet aka 400 square feet or 40 square meters. Given that Dan Simmons is a renowned American writer, it's not likely that he just can't speak English correctly. So, who's right and who's wrong here? How to use CDF and PDF statistics for analysis This may be too much of a general question but I hope I can find help here. I am starting a RA job in my university and my topic will be related to Internet Traffic Analysis. I am fairly new to the world of analysis but I guess in the world of research this is what I have to do a lot of.  I've been through a few papers and in a lot of them I find they use Probability Density (PDF), CDF, CCDF etc to explain the results they've obtained. For example, PDF of user session duration, CDF of bytes transferred each day etc. I have taken probability and statistics class so I understand what they are but I am still confused to the cases in which such representation would be chosen.  So, if there is anyone out there who does such graphs and analysis (in any other topic in general or this) could you tell me simply in what situation would I use one or the other of these representations Wavy stream of liquid While pouring a liquid into a glass from a bottle, some streams have a wavy shape, like the one in the following photo:    What causes the stream to be of such a shape? Bounding lines around tax nodes I am trying to draw lines around a number of nodes. I very much like the definition of \convexpath definition given , but it is not working well on my setup (MacTex 2014 with all available updates).   I tried to compile , but what I get is the following, which is clearly not what I should be getting. Any ideas would be much appreciated. Can someone tell me how to get a closed form for  $$\sum_{k=1}^n k^p$$  For $p = 1$, it's just the classic $\frac{n(n+1)}2$.   What is it for $p &gt; 1$? Zip all files in directory? Is there a way to zip all files in a given directory with the zip command? I've heard of using *.*, but I want it to work for extensionless files, too. Proof Verification: Converse of Intermediate Value Theorem Counting lines, words, characters and top ten words? As the title says: Is a 1st-level spell cast using a 4th-level slot a 1st-level spell, or a 4th-level spell? I love apples. I like to eat them with skin as it has plenty of fiber in the skin. But apples are famous for wax and pesticides on the skin which I don’t want to ingest. I have read many articles on the web and suggestions for removing the wax from the surface.   These suggestions include soaking in vinegar or hot water and other methods. They suggest that soaking apples in vinegar removes the wax that can be seen in the vinegar. I have done that, but never seen any residue of wax in the vinegar.   So I have set aside a new kitchen sink Scotch-Brite scrubber for this purpose and been scrubbing the apple skin under running water before eating. I think this method should remove most of the wax and pesticides. I would like to hear your input. Laser positioning on barn door tracker Subsections as an enumerate I want to have subsections named all the same with a number behind it. The straight forward approach I came up with is this:   \section{User Stories} \subsection*{Userstory 1} This is story 1 \subsection*{Userstory 2} This is story 2   But I though isn't this possible as a list? So I have tried a few things but none worked. I have just learned the basics of LaTeX, and I want to try some more advanced tricks in LateX, but it won't work. I have tried this and some things very similar to this:   \section{User Stories} \begin{enumerate} [label=\subsection*{Userstory \arabic*}]     \item This is story 1     \item This is story 2 \end{enumerate}   Is this behaviour even possible to automatically? What is the best approach, for not typing the number and the title every time. Thanks in advance! Can I mount the root (system) filesystem as writable in Big Sur? I have a question regarding selections in ArcGIS for Desktop. Assumed I have one layer in ArcMap and I have selected two of five features.   Is it possible to get a list of all selected features by using Python?   It would be fine if there is a way to get one special (or all) attribute(s) of the selected features stored in a list that can be written into a txt file.  Is it possible to do this in ArcGIS for Desktop? This is similar to , but I believe it's a bit different*.  Sites like GMail support a preference that pushes all traffic through the SSL edition of the site rather than the plain-text protocol.   For sites that don't offer such preferences (or ones that may, but I have been unable to find, like facebook), is there a way using only the browser (perhaps with a plugin or addon) to always try SSL first, and fall-back to plain-text iff SSL fails?  Is that solution available on Windows, Mac OS X, and Linux? Just one?     * The previous question was looking for external applications that would accomplish this goal.