We don't have the cp1251 code page available on a phone, so new String( data, "cp1251" ) doesn't work.
We need a function with signature something like
String ArrayCp1251toUTF8String(byte data[]);
...
How to transcode Windows-1251 to UTF-8?
Will such function do it?
function win_to_utf($s)
{
for($i=0, $m=strlen($s); $i<$m; $i++)
{
$c=ord($s[$i]);
if ($c<=127)
{$t.=chr($c); continue; }
if ($c>=192 && $c<=207)
{$t.=chr(208).chr($c-48); continue; }
if ($c>=208 && $c<=239)
{$t.=chr(208).chr($c-48); continue; }
if ($c>=240 && ...
I have UTF8 encoded String, but I need to post parameters to Runtime process in cp1251. How can I decode String or byte array?
I need smth like:.bytesInCp1251 = encodeTo(stringInUtf8, "cp1251");
Thanks to all! This is my own solution:
OutputStreamWriter writer = new OutputStreamWriter(out, "cp1251");
writer.write(s);
...