Chinese Characters in IDOC are lost

Hello,
I am using wm 6.5. I will get an idoc from SAP. I use transformFlatToHeirarchy service to convetr the stream into an idoc document I created using DTD. But in this process the chinese characters in the idoc data are being lost. I am seeing squares. What might be the problem. I heard that chinese characters are double byte. Then shall I need to install a patch on the server?

Guna

Hi Guna,
first of all: if the characters are displayed as “squares”, then it most probably means, they are ok! It means, you did not yet correctly modify the font settings of the Java VM, which starts your Developer, so the Developer can’t display the characters… If the characters were really broken, then you would see something like “?” or “#” for each char, depending on whether the data got broken during a wrong conversion inside the (Server) Java VM or during a wrong conversion during RFC communication.

Go to the “lib” directory inside the installation directory of the JDK used by your Developer and then rename the following files:
font.properties → font.properties_bak
font.properties.zh → font.properties

Another way to verify, that the data is still ok, is: add a savePipelineToFile as the very first step of your Flow and give the fileName the extension “.xml”. Afterwards open the file with InternetExplorer. IE should be able to display the Chinese characters correctly.

Cheers, Lanzelot

Hi Lanzelot,

Thanks. Actually I did that way and it worked.

Cheers
Guna

Hi, I need to convert the string to utf-8 encoding.Input string is 简体ä¸*文输入 and i want the output as 简体中文输入.I have written the below code for this requirement.But i am getting the same input value string as output.Pls chk and tell whats wrong in my code.

// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String input = IDataUtil.getString( pipelineCursor, “input” );
pipelineCursor.destroy();
try{
byte utf8Bytes = input.getBytes(“UTF8”);
String output = new String(utf8Bytes, “UTF8”);

// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
IDataUtil.put( pipelineCursor_1, “Output”, output);
pipelineCursor_1.destroy();
}

catch (UnsupportedEncodingException e) {
e.printStackTrace();
}

In Java, String’s internal encoding is UTF-16.
So when it’s coming in as input (String type), it’s already in UTF-16.
this line:
byte utf8Bytes = input.getBytes(“UTF8”);

utf8Bytes will have UTF-8 encoded Bytes → this is what you want, you need to print this out as bytes.

by this line:

String output = new String(utf8Bytes, “UTF8”);
you convert it back to a Java String, again it’s in UTF-16.

My guess is that your original String input is not properly encoded already, so you won’t have correct output, no matter what. Confirm your original encoding, don’t use String, just use bytes to carry your content.

Hi,
I am trying to store the file name with chinese characters.Example like 汉字/漢字.txt.But i am getting the below error
java.io.FileNotFoundException: Z:汉字漢字.txt (The filename, directory name, or volume label syntax is incorrect).
when i am trying to store as abc.txt its working fine.Below is my code.Can anyone help pls…

byte[] bytes = (byte[]) in.getValue( "bytes" );
String inStr = in.getString( "userData" );
String fileName = in.getString( "fileName" );

if( fileName == null )
    throw new RuntimeException( "fileName is null" );


try
{

FileOutputStream fos = new FileOutputStream( new File(fileName) );

if( inStr != null )
    fos.write( inStr.getBytes(), 0, inStr.length() );

if( bytes != null )
    fos.write( bytes, 0, bytes.length );

fos.close();
}
catch( Exception e )
{
    out.put( "errorMsg", e.toString() );
}

Are you using SAP Adapter which is the issues for this section?

For this issue:
“I am trying to store the file name with chinese characters.Example like 汉字/漢字.txt.But i am getting the below error
java.io.FileNotFoundException: Z:汉字漢字.txt (The filename, directory name, or volume label syntax is incorrect).
when i am trying to store as abc.txt its working fine.Below is my code.Can anyone help pls…”

Your filename is in certain encoding, but your OS may not support it.
enable the support to the Chinese locale in windows, and convert the filename encoding to the right encoding before trying to save it.

No.We are not using any SAP adapter.I think some settings need to done in WEbMethods .We are using webmethods 6.1.Could you pls advice.

YES please try the above from tongwang:

HTH,
RMg

You are in the wrong section then.

Also please try the above from tongwang:

HTH,
RMg