unicode question for tcl
Will Coleda
will at coleda.com
Wed Jun 10 00:39:43 UTC 2009
On Tue, Jun 9, 2009 at 4:21 PM, Patrick R. Michaud<pmichaud at pobox.com> wrote:
> On Mon, Jun 08, 2009 at 11:54:11PM -0400, Will Coleda wrote:
>> The tcl spec test "string.test" fails with:
>>
>> Invalid character for UTF-8 encoding
>>
>> This is due to the following tcl test:
>>
>> test string-24.5 {string reverse command - shared unicode string} {
>> set x abcde\udead
>> string reverse $x
>> } \udeadedcba
>>
>> I can't see a way to generate this string (\udead) in parrot, with
>> various failures on utf16, utf8, and ucs2.
>
> In my reading of the Unicode specs [1], it looks as though Parrot has
> this one correct. U+DEAD isn't a valid standalone Unicode character --
> it falls in the U+DC00..U+DFFF range of surrogates; "Surrogates are
> reserved for use with UTF-16 and then must be used in pairs."
>
> [1] http://www.unicode.org/charts/PDF/UDC00.pdf
>
> So, I'd claim that the tcl spectest itself is an invalid
> test, at least to the extent that it claims to be following Unicode.
> The truth is simply that \udead isn't a valid Unicode character.
> (Whether you can get the tcl folks to agree may be a different
> matter.)
>
> At any rate, it seems the only encoding for which this can
> possibly work is utf16.
>
> Pm
>
Spoke with kbk on #tcl on freenode.
In tcl, this does parse, and generate an (invalid) unicode string. I
settled for converting any invalid chars to \ufffd (where invalid is
between 0xd7ff and 0xe000), to at least get me over the hump for now,
even if the behavior is different than core tcl.
Thanks.
--
Will "Coke" Coleda
More information about the parrot-dev
mailing list