[Lazarus] Windows and german Umlauts: why do i have to PWideChar(UTF8Decode(String)) and not UTF8ToAnsi(String)

Mattias Gaertner nc-gaertnma at netcologne.de
Tue Oct 18 09:36:12 CEST 2016


On Tue, 18 Oct 2016 09:15:15 +0200
Landmesser John via Lazarus <lazarus at lists.lazarus-ide.org> wrote:

> I know how to deal with german Umlauts but I would like to understand.
> 
> Think of a  *.csv file that contains strings like "Gr├╝nberg" and that 
> has to be opened in Excel ( Office 2003 ).
> 
> It works if i use PWideChar(UTF8Decode(String)). Got this tipp here in 
> the mailinglist!
> 
> But  UTF8ToAnsi(String) fails.
> 
> Why is UTF8ToAnsi(String) not enough?
> 
> LHelp tells me about  UTF8ToAnsi():
> "Utf8ToAnsi converts an utf8-encode unicode string to an ansistring. It 
> converts the string to a widestring and then converts the widestring to 
> an ansistring."
> 
> That is NOT  the same as  PWideChar(UTF8Decode(String))?

Obviously, because one produces an 8-bit string and the other a 16-bit
string. How do you compare the result?

What compiler version?
Are you using LazUTF8? What is your DefaultSystemCodePage?

Mattias


More information about the Lazarus mailing list