?

Log in

No account? Create an account
Posting special characters in Music and Mood fields in XML-RPC - LiveJournal Client Discussions [entries|archive|friends|userinfo]
LiveJournal Client Discussions

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Posting special characters in Music and Mood fields in XML-RPC [May. 23rd, 2004|09:24 pm]
LiveJournal Client Discussions

lj_clients

[krolain]
[mood |accomplishedaccomplished]

Evening everyone.

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.
linkReply

Comments:
From: evan
2004-05-24 06:41 am (UTC)
it would seem you could send utf-8 text directly. does that not work? (are you sure the xml declaration in the request includes that it's using utf-8?)
(Reply) (Thread)
[User Picture]From: krolain
2004-05-24 07:34 am (UTC)
Well, I'm using UTF-8 since I can post those characters in the subject and event fields without having to use base64 binary (which is the way I do it now). Plus I set my connection to livejournal to use 'UTF-8', which encodes all text in UTF-8. And yes, I do put the encoding of utf-8 in the XML declaration
(is what you mean right?)

However, whenever I try to use those same characters in the music and emotion fields, the server says that it can't post.

I only encountered this problem with XML-RPC protocol. I had no problem with the flat-protocol. Then again, with the flat protocol, JAVA comes with a text URL Encoder, which encoded the special characters properly (in UTF-8). But I haven't found an XML text encoder, which may be part of the problem.

Still, what I found strange is that I could post the special character in subject and event field, but I couldn't use the same method for the music or mood field.

Maybe I am missing something, but for the life of me, I don't know what. Still, it seems this answer is working. Why can I post the special characters in the event/subject fields, but not in the mood/music field, without having to base64 binary encode it?
(Reply) (Parent) (Thread)
From: cryptoalex
2004-05-28 03:49 am (UTC)
Yes, i also confirm this bug: direct utf-8 doesnot help.

2krolain: Thanks for finding solution.
(Reply) (Parent) (Thread)
[User Picture]From: krolain
2004-05-29 03:15 am (UTC)
My pleasure. And thanks for confirming the bug.
(Reply) (Parent) (Thread)