Re: [Chicken-users] problems string-trimming on UTF8

2017-01-27 Thread Peter Bex
On Fri, Jan 27, 2017 at 02:36:55PM +0100, Kristian Lein-Mathisen wrote:
> Oh no, what happened?
> 
> $ csi -R utf8 -R srfi-13 -p '(string-trim-right "Zazà")'
> Zaz�
> 
> 
> utf8 doesn't seem to do it! But utf8, at least, gets the string-length
> right:
> 
> $ csi -R srfi-13 -p '(string-length "Zazà")'
> 5
> $ csi -R utf8 -R srfi-13 -p '(string-length "Zazà")'
> 4
> 
> It took me a while to figure out what was going on. These are the bytes of
> Zazà:
> 
> $ printf 'Zazà' | xxd
> : 5a61 7ac3 a0 Zaz..

The srfi-13 module is pretty FUBAR: together with srfi-14, they both
assume latin1.  That's why the utf-8 module ships with a utf-8-srfi-13
module:

$ csi -R utf8 -R utf8-srfi-13 -p '(string-trim-right "Zazà")'
Zazà

Cheers,
Peter


signature.asc
Description: Digital signature
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] problems string-trimming on UTF8

2017-01-27 Thread Kooda
On Fri, 27 Jan 2017 14:36:55 +0100
Kristian Lein-Mathisen  wrote:

> $ csi -R srfi-13 -p '(string-trim-right "Zazà")'
> Zaz�
> 
> 
> Oh no, what happened?

Please use the utf-8 aware srfi-13, called utf8-srfi-13:

$ csi -R utf8-srfi-13 -p '(string-trim-right "Zazà")'
Zazà


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users