|
List Info
Thread: TStringStream and the EURO symbol
|
|
| TStringStream and the EURO symbol |

|
2006-05-29 08:10:52 |
|
I use the TStringStream to read an XML file. All works well, except for reading the Euro sign.
From within the file delicered from the customer; the euro sign is $AC . Reading this file within any windows viewer, It a proper E sign. However, within the read string from my xlm parser, it a secial char ( something like a ----i ). Exporting a Euro sign will result in a € and this will be re-imported properly. Viewing a E sign after typing it into a notepad txt, will result in a $80.
Can I use a TStringStream via the property DataString to read unicode characters? Browsing the internet, it seems that the char $20AC is to correct way to show the original eurosign. Should I change my way to read unicode strings/ characters?
Any ideas?
Andries
---------------------------------
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.
[Non-text portions of this message have been removed]
|
| TStringStream and the EURO symbol |

|
2006-05-29 16:03:43 |
|
> I use the TStringStream to read an XML file. All works well, except
> for reading the Euro sign.
>
> From within the file delicered from the customer; the euro sign is
> $AC . Reading this file within any windows viewer, It a proper E
> sign. However, within the read string from my xlm parser, it a secial
> char ( something like a ----i ). Exporting a Euro sign will result
> in a € and this will be re-imported properly. Viewing a E sign
> after typing it into a notepad txt, will result in a $80.
>
> Can I use a TStringStream via the property DataString to read
> unicode characters? Browsing the internet, it seems that the char
> $20AC is to correct way to show the original eurosign. Should I
> change my way to read unicode strings/ characters?
In certain character sets, the euro sign resides at character code $80.
In Unicode, it is at code $20ac, which is the only code an XML parser is
interested in since XML always uses Unicode.
However, an XML file may be *encoded* using any character set. The
<?xml?> processing directive at the top of the file should tell you what
encoding was used. Also consider whether the file starts with any
Unicode byte-order mark. If there is no byte-order mark, and the
processing directive has no encoding property, then you should assume
the file is encoded as UTF-8.
Your XML parser should expect a WideString as input. If it expects an
AnsiString, then it's probably not written correctly. (It *might* expect
an AnsiString encoded with UTF-8, but that's unlikely.) Read your XML
file and transcode it to be UTF-16, which is the encoding Delphi's
WideString type expects to hold. Your XML library might even have
functions for changing a string's character encoding.
--
Rob
|
[1-2]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|