Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.forth Subject: Re: Reverse a string (with xchars) Date: Sun, 21 Feb 2016 12:07:53 -0800 Organization: A noiseless patient Spider Lines: 15 Message-ID: <874md16d46.fsf@jester.gateway.pace.com> References: <2016Feb19.100032@mips.complang.tuwien.ac.at> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="3c7a0b0f75f6c95b248ff930d17c36e7"; logging-data="5910"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Uj1HlK6kdU1WP9q1cIyWe" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:f0oP9+QI4NoRxXcve0VrNZR9L/k= sha1:CZeNklPqWA6QUWp2BoslNM3EaXw= Xref: csiph.com comp.lang.forth:45658 Chris Curl writes: > Since each unicode UTF-16 character is 2 bytes instead of 1, why > wouldn't something like this work? UTF-16 is a variable length encoding, like UTF-8. Remember there are more than a million Unicode code points. So you can't always specify one with 2 bytes. Plus as Anton says, there is the issue of composing characters: https://en.wikipedia.org/wiki/Unicode_normalization That means certain characters with diacritics have multiple encodings some of which use more than one code point, and you have to handle reversing them.