[fpc-pascal] problems using utf8toansi

Marc Santhoff M.Santhoff at t-online.de
Fri Dec 7 07:43:20 CET 2007


Hi,

when using system.utf8toansi() the result is an empty string as soon as
I put in some special chars:

<code>
{$H+}
...
fDescription: String;
...

 function sDecode(sin: string): string; inline;
  begin
  	result := utf8toansi(sin);
  end;

...

fDescription := sDecode(Item[i].FirstChild.NodeValue);
writeln('dbg: '+Item[i].FirstChild.NodeValue);
writeln('dbg: '+fDescription);
</code>

<input>
 Description
testing, one, two ...
€ à 
</input>

<xml>
<dc:description> Description
testing, one, two ...
€</dc:description>
</xml>

<output>
dbg: Description
testing, one, two ...
? à 
dbg: 
</output>

Using german umlauts the same happens, the string is empty. When feeding
in plain ascii the output is okay, the string is actually filled.

I fear this is another problem using the rather old fpc 2.0.4, but
what's going on here?

TIA,
Marc





More information about the fpc-pascal mailing list