DHI / mikecore-python

MIKE Core in Python
5 stars 0 forks source link

Char decode encode #6

Closed jsmariegaard closed 3 years ago

jsmariegaard commented 3 years ago

Up to now, conversions between python strings and c char arrays was done assuming ascii. This gives an error if æøå or other none ascii characters are used.

jsmariegaard commented 3 years ago

utf-8 is not optimal - as it will give "Hornb�k" instead of "Hornbæk" in the below test...

jsmariegaard commented 3 years ago

decode("iso-8859-1") would fix the problem in this case but is of course not a general solution

JesperGr commented 3 years ago

Question if UTF-8 is the right encoding to use, but I would not know of any better. The MIKE Zero Tools etc. are based on the Microsoft MBCS (MultiByte Character Set) encoding, but I guess that is not supported from within Python. MBCS and UTF-8 agrees on more characters than just ascii, hence also the danish æøå.

jsmariegaard commented 3 years ago

I now replaced all uses of utf-8 with cp1252. Hope this is the right thing to do. At least the new tests are passing :-)

ecomodeller commented 3 years ago

I now replaced all uses of utf-8 with cp1252. Hope this is the right thing to do. At least the new tests are passing :-)

So not possible to have 🌊 for metocean or 💩 for bathing water in the item names 😄 ?