Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.pascal.delphi.misc > #75
| From | Hans-Peter Diettrich <DrDiettrich1@aol.com> |
|---|---|
| Newsgroups | comp.lang.pascal.delphi.misc |
| Subject | RawByteString and SetCodePage buggy? |
| Date | 2011-09-18 15:28 +0200 |
| Message-ID | <9dm6feFvk3U1@mid.individual.net> (permalink) |
I just noticed very strange behaviour of RawByteString and SetCodepage,
in Delphi XE:
var //used as arguments for test()
a: AnsiString; //initialized to 'abcäöüß012'
u: UnicodeString; //initialized to a
procedure test(r: RawByteString; cp: word);
begin
WriteLn('in: ', StringElementSize(r), ' cp: ', StringCodePage(r), '
len=', length(r));
WriteLn('"', r, '"'); //writes garbage for non-OEM chars, of course
SetCodePage(r, cp, true);
WriteLn('out: ', StringElementSize(r), ' cp: ', StringCodePage(r), '
len=', length(r));
a := r; //use the result, so that nothing can be optimized away
WriteLn('"', r, '"');
end;
This reveals the following behaviour:
1) UnicodeString is converted to AnsiString, before passed to test.
2) Setting codepage to 1200 doesn't change anything???
3) Conversion to UTF-8 seems to work (length changed).
4) Conversion from UTF-8 to Ansi results in an empty string???
At least #4 looks like a bug?
What about #2?
DoDi
Back to comp.lang.pascal.delphi.misc | Previous | Next | Find similar
RawByteString and SetCodePage buggy? Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2011-09-18 15:28 +0200
csiph-web