Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

arabic characters corrupt before reaching database

Status
Not open for further replies.

Phathutshedzo

Technical User
Sep 10, 2008
3
ZA
Detailed Scenario.
1. The problem comes when we input Arabic characters in any of the data window. The characters become "?" by the time the data reaches our DLL. Hence for this particular transaction the arabic data is captured as a series of ? in the application DB too(Oracle on unix box).
2. PLs note that we want to achieve smooth transition of Arabic data with Regional Settings as English.
3. If I change the regional settings to Arabic, everything works fine.

To further understand the problem, pls note the following snapshots/snippets of code -
1. In the VC++ DLL we have published a function "write_to_file" that expects a string from the frontend/PB. This string is printed to a txt file on the client machine.

extern "C" _declspec(dllexport) long _stdcall write_to_file(char * str)
{
FILE * fp = fopen("D:\\arabic_text.txt","w");
if (fp == NULL)
return -1;

char * str1 = "? ? ?";
fprintf(fp,"static text %s\n",str1);
fprintf(fp,"from appln %s\n",str);
fclose(fp);
return 0;
}

2. In Powerbuilder this function was published as a local external function , which is called by the PB window with the string as input.

Function declaration is as follows - FUNCTION long write_to_file(String str)Library "qz32.dll" alias for "write_to_file;Ansi"

The PB window code snippet -
ue_printtofile( )
{
......
String value1
value1 = this.dw_2.GetItemString(1,"value")
Messagebox("Value",value1)
write_to_file(value1)
.....
}

Observations: The static text string "str1" also has three arabic characters that are being being printed fine to the flat file. The problem is with the string that we receive from the PB window.

For the sake of simplicity I have sent the same three Arabic characters from the PB screen that I have hardcoded in the DLL.
Hence if in debug mode (VC++ DLL) I examine the memory location ( of string coming as input) and compare it with the contents of the static/hardcoded string str1, I can very clearly see that the character codes are different.


In the beginning....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top