views:

424

answers:

2

Im wondering how I can display a Euro symbol in UTF-8 Format ?

Cheers

A: 

You can display it like this: €

klausbyskov
The 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
You 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.
David Dorward
In iso-8859-15, the € symbol is represented by `0xA4`, replacing a different character from iso-8859-1; in windows-1252, it's `0x80`. So the various single-byte encodings vary in their placement of this symbol - UTF-8 is simply safer.
Tim Pietzcker
Hey 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
Maybe 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
Hey 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..
StevieB
@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.
bobince
You should understand what encodings are. The canonical link at this point would be [Spolsky's](http://www.joelonsoftware.com/articles/Unicode.html). How are you creating these files? Where are you writing a `€`? Does it come from code? What does the code look like?
bobince
In Visual Studio do I need to select UTF-8 with or without signature
StevieB
The 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 thisXMLwriter.WriteElementString("Prim_Status", reader_image["Prim_Status"].ToString());
StevieB
You could just use unicode escape sequence in your strings (\u20AC for euro). In example: Console.WriteLine("I need \u20AC") would output I need €
Ivan
+1  A: 

Euro symbol has unicode code U+20AC (decimal 8364) encoded in utf8 it translates to following bytes e2 82 ac

Ivan
Im sorry I do not understand your answer. So I need to replace € with "e2 82 ac" is it ?
StevieB
Nope, it's just a way it's binary coded in utf8 file. If you just need to output it you can just paste €.
Ivan