0

I am trying to save this Swedish string "120918_demo_öar.jpg" to MySQL database. Strangely, the value that is getting stored in the database is "120918_demo_o¨ar.jpg"

Initially, I thought this was a MySQL issue, but found out that that was not the case.

In code, I get this string "120918_demo_öar.jpg" by parsing XML stored in an SQL Server Database table. The string is stored to a variable named imgName

If I do, imgName == "120918_demo_öar.jpg", it gives false and imgName.Equals("120918_demo_öar.jpg") also gives false

I have no idea what the issue is. Please help

Thanks in advance
Vivek

Vivek
  • 382
  • 4
  • 12
  • What collation is your database set to use? – DavidG Oct 14 '14 at 08:25
  • So what do you get if you do `Console.WriteLine(imgName)` after parsing it from the XML file? Are you sure the XML file is using UTF8 encoding? – Matthew Watson Oct 14 '14 at 08:27
  • @DavidG The collation is utf8_general_ci – Vivek Oct 14 '14 at 08:30
  • @MatthewWatson I was wrong to say that I get this by parsing an XML file. The content is being parsed from XML stored in SQL Server table(Specifically, cmsContentXML table of Umbraco). What is strange about this is that some other Swedish text in the same XML file is being written correctly Sorry for the wrong information about XML – Vivek Oct 14 '14 at 08:34
  • 1
    The value that is stored in database looks like a normalized version of your string. (Some characters are displayed the same way but are different on binary level) Check if imgName.Normalize(NormalizationForm.FormKD).Equals("120918_demo_öar.jpg".Normalize(NormalizationForm.FormKD)); also: http://msdn.microsoft.com/en-us/library/ebza6ck1(v=vs.110).aspx – Arie Oct 14 '14 at 08:35
  • @Arie - The code `imgName.Normalize(NormalizationForm.FormKD).Equals("120918_demo_öar.jpg".Normali‌​ze(NormalizationForm.FormKD));` gives true – Vivek Oct 14 '14 at 08:39
  • then it seems to be a normalization issue. check this out: http://stackoverflow.com/a/1036459/891715 – Arie Oct 14 '14 at 08:43

0 Answers0