- protected String CP1251toUTF8(String str)
- {
- StringBuffer buffer = new StringBuffer();
- for(int i=0; i<str.toCharArray().length; i++) {
- char ch = str.toCharArray()[i];
- if (ch>=192 && ch<=239) buffer.append(new String(new byte[]{(byte)208, (byte)(ch-48)}));
- else if (ch>239) buffer.append(new String(new byte[]{(byte)209, (byte)(ch-112)}));
- else if (ch==184) buffer.append(new String(new byte[]{(byte)209, (byte)209}));
- else if (ch==168) buffer.append(new String(new byte[]{(byte)208, (byte)129}));
- else buffer.append(ch);
- }
- return buffer.toString();
- }