[elephant-devel] Bug in string serialisation?

Pierre THIERRY nowhere.man at levallois.eu.org
Thu Jan 25 23:40:33 UTC 2007


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <https://mailman.common-lisp.net/pipermail/elephant-devel/attachments/20070126/f4ce5f12/attachment.sig>


More information about the elephant-devel mailing list