[elephant-devel] Bug in string serialisation?

Ian Eslick eslick at csail.mit.edu
Fri Jan 26 00:59:10 UTC 2007


We need a good set of unicode tests!  I redesigned unicode support in  
0.6.1 so I'm hoping these issues will go away, but I'd like to  
understand it.

What lisp are you using and what character coding, etc?

Ian

On Jan 25, 2007, at 6:40 PM, Pierre THIERRY wrote:

> I'm working on a web application that uses 0.6.0, and I may have hit a
> bug in Elephant.
>
> I have a fairly reproducible bug, when storing a string. I sometimes
> have to decode a badly-read string. E.g.:
>
> - I have "Idéal"
> - I want "Idéal"
>
> For this I use a function that if the à character is found, decode  
> the
> string from UTF-8.
>
> (decode-string-if-needed "Idéal") => "Idéal"
> (decode-string-if-needed "Idéal") => "Idéal"
>
> The problem is when I store the result in a slot of a persistent  
> class.
> I tried to store it manually quite some times, I never had any  
> problem:
>
> (setf (product-description p) "Idéal")
> (product-description p) => "Idéal"
>
> As illogic as it seems, if the slot is "Idéal", the following:
>
> (setf (product-description p) (decode-string-if-needed (product- 
> description p)))
>
> doesn't have the same result. If I retrieve the string from the slot,
> usually swank deconnects because it encountered strange characters.
>
> (map 'vector #'char-code "Idéal") => #(73 100 233 97 108)
> (map 'vector #'char-code (product-description p)) => #(39 24  
> 8483047 0 11)
>
>
> I wrote the following test macro:
>
> (defmacro test-conversion (location)
>  `(let* ((bad ,location)
>          (good (decode-string-if-needed bad))
>     (setf ,location good)
>     (let ((stored ,location))
>       (mapcar (lambda (string) (map 'vector #'char-code string))  
> (list bad good stored))))))
>
> And I reliably got the following:
>
> (setf (product-description p) "Idéal")
> (test-conversion (product-description p))
> => (#(73 100 195 169 97 108)
>     #(73 100 233 97 108)
>     #(39 24 15187975 0 11))
>
> Does someone understand what could be going on?
>
> Strangely,
> Pierre
> -- 
> nowhere.man at levallois.eu.org
> OpenPGP 0xD9D50D8A
> _______________________________________________
> elephant-devel site list
> elephant-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/elephant-devel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
URL: <https://mailman.common-lisp.net/pipermail/elephant-devel/attachments/20070125/e5bd75a1/attachment.sig>


More information about the elephant-devel mailing list