In Java Is it possible to convert character set 1047 into another character set, say 500? -
In Java Is it possible to convert character set 1047 into another character set, say 500? -
i have programme reads message mq. character set 1047. since java version old doesn't back upwards character set.
is possible alter string char set 500 in programme after receiving before reading.
for eg:
public void fun (string str){ //str in char set 1047. **1047 not supported in system** /* can convert str char set 500 here. convert byte stream , string. */ byte [] b=str.getbytes(); bytearrayoutputstream baos = null; try{ baos = new bytearrayoutputstream(); baos.write(b); string str = baos.tostring("ibm-500"); system.out.println(str); }
byte [] b=str.getbytes(); //will convert string(encoding unicode in jvm) bytes using file.encoding. should check whether str contains right information, if so, need not care 1047 encoding, run str.getbytes("ibm-500"), 500 encoded bytes. again, string object utilize unicode, if convert string bytes, encoding matters result bytes array.
java character-encoding
Comments
Post a Comment