|Posting special characters in Music and Mood fields in XML-RPC
||[May. 23rd, 2004|09:24 pm]
LiveJournal Client Discussions
I have some information I'd like to share with some of you. I know some of you, like me, have been trying to figure out how to post non-english characters in the mood and music field of LJ though the XML-RPC protocol. Well, after a good six hours of fooling around, I figured it out.
The best way is to encode the text into base64-encoded binary. I stumbled upon this answer when one of my post ended up being sent to me in binary. I knew it was text since it was a post that I used the 'é' character. Once I decoded the binary into bytes, then UTF-8 decoded that, the text appeared correctly.
So, the way to do it is:
1. UTF-8 byte encode the text
2. Encode the bytes into base64-encoded binary
That seems to work! :-) I may use base64 binary for all my text posting onto LJ! Though, this may be only needed for the music and mood field, since so far, the subject and event fields handle non-english characters. However, if you have problem with any valid unicode characters, try this method and see what happens.
However, if you this, ensure that your XML-RPC handler can decode the base64 binary back into text, since LJ will send back those field in base64 binary.