Display EURO Symbol in UTF-8 Format
15,369
Solution 1
You can display it like this: €
Solution 2
Euro symbol has unicode code U+20AC (decimal 8364) encoded in utf8 it translates to following bytes e2 82 ac
Author by
StevieB
Updated on June 04, 2022Comments
-
StevieB about 2 years
Im wondering how I can display a Euro symbol in UTF-8 Format ?
Cheers
-
StevieB about 14 yearsThe feedback I received was as follows after my symbol was indeed like the above in a XML file. "The euro symbol in this text is not encoded correctly and needs to be in UTF-8" What could be meant by that
-
StevieB about 14 yearsIm sorry I do not understand your answer. So I need to replace € with "e2 82 ac" is it ?
-
Quentin about 14 yearsYou need to make sure that the (unspecified) software you are using is saving the file in UTF-8 format and nothing is converting it to a different format along the way.
-
Tim Pietzcker about 14 yearsIn iso-8859-15, the € symbol is represented by
0xA4
, replacing a different character from iso-8859-1; in windows-1252, it's0x80
. So the various single-byte encodings vary in their placement of this symbol - UTF-8 is simply safer. -
StevieB about 14 yearsHey I am creating a XML in a project in Visual Studio using XmlTextWriter. I just noticed I have the following line of code Encoding utf8 = new UTF8Encoding(false); Should this be set to true ?
-
StevieB about 14 yearsMaybe I will make more sense like this to. Ok at the moment my euro symbol is displayed as € in my XML. After I somehow get UTF-8 encoding working how do it look like after ?
-
StevieB about 14 yearsHey bobince. Thanks for your reply. But my XML Files are created dynamically ever 15 mins or so I need to do this "UTF-8 encoding of euro symbols" somehow dynamically. Can you suggest a way i can do this via my script ? I dont understand how € differs from € in UTF-8..
-
Amit Patil about 14 years@StevieB: no,
new UTF8Encoding(false)
is fine.true
would add a UTF-8-encoded faux-BOM, which in general you don't want. If you are talking about writing€
in an XML file, just write€
in the file in a text editor and use ‘Save as’ to save it in the UTF-8 encoding. If you're editing in Visual Studio, I believe the encoding is in File->Advanced Save Options. It totally sucks that Windows tools still default to some useless system default codepage instead of UTF-8. -
Amit Patil about 14 yearsYou should understand what encodings are. The canonical link at this point would be Spolsky's. How are you creating these files? Where are you writing a
€
? Does it come from code? What does the code look like? -
StevieB about 14 yearsIn Visual Studio do I need to select UTF-8 with or without signature
-
StevieB about 14 yearsThe files are created from a .NET script. Im writing the € in out of the elements of the XML File. The value € is pulled from the database, which was entered in the first play via CMS. Code looks i.e sample something like this XMLwriter.WriteElementString("Prim_Status", reader_image["Prim_Status"].ToString());
-
Ivan about 14 yearsNope, it's just a way it's binary coded in utf8 file. If you just need to output it you can just paste €.
-
Ivan about 14 yearsYou could just use unicode escape sequence in your strings (\u20AC for euro). In example: Console.WriteLine("I need \u20AC") would output I need €