How to post non-latin1 data to non-UTF8 site using perl?

Posted by ZyX on Stack Overflow See other posts from Stack Overflow or by ZyX
Published on 2010-06-03T00:40:01Z Indexed on 2010/06/03 0:44 UTC
Read the original article Hit count: 289

Filed under:
|
|
|

I want to post russian text on a CP1251 site using LWP::UserAgent and get following results:

$text="??????? ?????";
FIELD_NAME => $text                                # result: ??? ?'???'???'?????????????? ?'?'?????????'???'?'
$text=Encode::decode_utf8($text);
FIELD_NAME => $text                                # result: ? ???????????? ?'???????'
FIELD_NAME => Encode::encode("cp1251", $text)     # result: ?????+?+?????? ???????+??
FIELD_NAME => URI::Escape::uri_escape_utf8($text) # result: D0%a0%d1%83%d1%81%d1%81%d0%ba%d0%b8%d0%b9%20%d1%82%d0%b5%d0%ba%d1%81%d1%82

How can I do this? Content-Type must be x-www-form-urlencoded. You can find similar form here, but there you can just escape any non-latin character using &#...; form, trying to escape it in FIELD_NAME results in 10561091108910891 10901077108210891 (every &, # and ; stripped out of the string).

© Stack Overflow or respective owner

Related posts about perl

Related posts about encoding