ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Unicode question
Date: Thu, 12 Mar 2015 19:55:49 +0100	[thread overview]
Message-ID: <5501E135.3040501@wxs.nl> (raw)
In-Reply-To: <20150312185749.0c7f677e@arcor.com>

On 3/12/2015 6:57 PM, Manfred Lotz wrote:
> On Thu, 12 Mar 2015 16:41:59 +0100
> Ulrike Fischer <news3@nililand.de> wrote:
>
>> Am Thu, 12 Mar 2015 08:48:27 +0100 schrieb Manfred Lotz:
>>
>>> Hi all,
>>> If I run this minimal example
>>>
>>> \starttext
>>>
>>> �
>>>
>>> \stopluacode
>>>
>>> \stoptext
>>>
>>>
>>> I get
>>>
>>> tex error       > error on line 3 in file /data/tmp/u1.tex: ! String
>>> contains an invalid utf-8 sequence
>>>
>>> and some more lines.
>>>
>>>
>>> The character above is:
>>>
>>>    Character: �
>>>     Character name: REPLACEMENT CHARACTER
>>>          Charblock: Specials
>>>           Category: Other symbol
>>>            Unicode: U+fffd
>>>               UTF8: 0xefbfbd
>>>
>>> which is a valid utf8 character.
>>>
>>> Questions:
>>>
>>> 1. Why is it considered to be invalid?
>>
>> This is not a context question/problem but related to the binary
>> (you would get the same error with lualatex or plain)
>>
>
> Yes, I know.
>
>> The luatex code contains the lines (in unistring.w)
>>
>> if (val == 0xFFFD)
>>          utf_error();
>>      return (val);
>>
>> in a function str2uni. I didn't really try to understand the code
>> but it looks as if 0xFFFD is used as "invalid marker": If luatex
>> encounters something that isn't valid utf8 it maps val to 0xFFFD and
>> then test against 0xFFFD to rise an error.
>>
>
> Took me a while to find the repository but finally I got it.
>
>
>>> 2. Are there other valid utf8 characters which are considered
>>> invalid?
>>
>> The comment in the code says
>>
>> /* the 5- and 6-byte UTF-8 sequences generate integers
>>
>> that are outside of the valid UCS range, and therefore
>>
>> unsupported
>>           */
>>
>
> Well, it is called REPLACEMENT CHARACTER, and it seems that this
> character will be used to replace invalid characters.  Then it causes
>   if (val == 0xFFFD)
>          utf_error();
>
> the error message
>      tex_error("String contains an invalid utf-8 sequence", hlp);
>
> to be displayed.
>
> Ok, this answers my question.
>
> Thanks for the pointer.

it's actually a bug ... it is ok to map an invalid character in the 
input to 0xFFFD, halt and continue when permitted, but the method used 
in luatex thereby obscures a valid 0xFFFD in the input

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2015-03-12 18:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-12  7:48 Manfred Lotz
2015-03-12 15:41 ` Ulrike Fischer
2015-03-12 16:35   ` Arthur Reutenauer
2015-03-12 18:08     ` Manfred Lotz
2015-03-12 19:04       ` Hans Hagen
2015-03-12 17:57   ` Manfred Lotz
2015-03-12 18:55     ` Hans Hagen [this message]
2015-03-12 20:41       ` luigi scarso
2015-03-12 20:52         ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5501E135.3040501@wxs.nl \
    --to=pragma@wxs.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).