-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Writing multibyte strings #3
Comments
It's a bug indeed. I'll make changes to the builder to allow specifying a default charset when creating the serializer. Also, I'll add a new parameter to Please allow me a few days to release a new version with the fixes. |
I just released the version 0.6.0 that covers this issue. Could you please check if it covers your use case? You can check the full release description here: I've also updated the docs to reflect the new feature: |
It works like a charm now. Thank you very match for your quick support. |
Closing as the issue has been fixed. |
The current implementation of
writeString
and maybe alsowriteProperty
andwriteKey
has the problem, that the length(s:<length>)
of multibyte strings is not written correctly. This results on the PHP side inunserialize() [function.unserialize]: Error at offset ...
Unfortunately, you must give the length of a serialized string in bytes instead of characters. However, the byte count depends on the character encoding.
When testing the serializer with a servlet I didn't immediately notice this, because the standard encoding of the output is ISO-8859-1 (one character is always one byte). Only when switching to UTF-8 (
response. setCharacterEncoding("UTF-8"
) and using german umlauts the problem came up.My instant fix for UTF-8 looks like this:
Writer.java:
It would certainly be better if the desired character encoding could be given to the writer.
Translated with www.DeepL.com/Translator.
The text was updated successfully, but these errors were encountered: