Locale, the time separator

1 minute read Published:

DateTime.Now.ToString("HH:mm:ss"); is a common mystake if you want to transmit to someone or to be sure that you have something like “HH:mm:ss” because the character (:) is not just a colon, it’s a time separator wich depend on the locale. Here is a list of culture where the (:) change into a dot (.) it-IT : Italian (Italy) fo-FO : Faroese (Faroe Islands) bn-BD : Bengali (Bangladesh) ml-IN : Malayalam (India)

XmlWriter and UTF-8 encoding without signature

1 minute read Published:

I used this code to serialize some objects in Xml : XmlWriter writer = new XmlTextWriter(stream, Encoding.UTF8); But the output contains an UTF header, the Byte Order Mark (BOM). The use of the header/signature is usually for xml file, if you want to use the ouput in an HttpResponse, you don’t need the signature. (some parser can cause a parsing error in java, like org.xml.sax.SAXException). Here is the change to remove the BOM :