help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with strrep


From: Jordi Gutiérrez Hermoso
Subject: Re: Problem with strrep
Date: Sun, 27 Feb 2011 06:14:07 -0600

2011/2/27 Pascal Grandeau <address@hidden>:
> Thank you.
> I study strrep and it seems the problem come from the function toascii used
> in strrep :
>>>> toascii("é")
>
> ans = 105
>
>>>> toascii("i")
>
> ans = 105

I think the problem of calling a function named "toascii" on non-ASCII
characters should be obvious. I see that you are probably using a
single-byte encoding for your French, probably ISO-8859-1, also known
as Latin-1 or Western European, since é seems to be represented on
your system as a single byte. When I run the same command on my UTF-8
system, where é is represented by two bytes, I get

     octave:1> toascii("é")
     ans =

        67   41

The call to toascii here is obviously to blame. Digging around a
little in the source code, it seems that it is ultimately delegated to
the C++ library function toascii, which is a POSIX function.

     http://pubs.opengroup.org/onlinepubs/9699919799/functions/toascii.html

I see that gnulib doesn't attempt to wrap this function, and its
specification is for unibyte encodings, so it's definitely the wrong
function to call on a non-ASCII encoding.

I don't think it's worthwhile trying to work around this error. Octave
3.4 seems to be doing the correct thing and respecting your system
locale without assuming it's all ASCII. Plus the algorithm that
Jaroslav implemented for it is faster.

If this problem is important enough for you, I think your time might
be well spent helping Ben and Tatsuro getting Octave 3.4 compiled on
Windows.

HTH,
- Jordi G. H.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]