[fpc-devel] Unicode conversion routines

Graeme Geldenhuys graemeg.lists at gmail.com
Sat Nov 22 19:55:22 CET 2008


On Sat, Nov 22, 2008 at 10:51 AM, Florian Klaempfl
<florian at freepascal.org> wrote:
> function UTF8Decode(const s : UTF8String): UnicodeString;

Is there some hard-coded limit on UTF8Decode?  I am writing some unit
tests for these methods and on my 3rd test, it already fails. I'm
using testing sample data from unicode.org.

var
  s8: UTF8String;
  s16: UnicodeString;
begin

  // U+289A8 CJK UNIFIED IDEOGRAPH-289A8
  s8 := Char($F0) + Char($A8) + Char($A6) + Char($A8);
  s16 := UTF8Decode(s8);

  AssertEquals('Failed on 4', 4, Length(s16));
  AssertEquals('Failed on 5', UnicodeChar($D862) + UnicodeChar($DDA8), s16)

end;

Test 4 fails: Expected 4 but was 0.
Test 5 fails: to due to Test 4 failure...


---------------[  from unicode description file ]-----------------------
U+289A8 CJK UNIFIED IDEOGRAPH-289A8

General Character Properties

Unicode category: Letter, Other

Various Useful Representations

UTF-8: 0xF0 0xA8 0xA6 0xA8
UTF-16: 0xD862 0xDDA8
------------------------[ end ]----------------------------


Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-devel mailing list