Consultor Eletrônico



Kbase P159121: Files with Asian language file names cannot be found in a UTF-8 session
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   4/21/2011
Status: Unverified

SYMPTOM(s):

Files with Asian language file names cannot be found in a UTF-8 session

OS-COPY fails to copy a Thai file selected with the SYSTEM-DIALOG interface.

OS-COPY cannot find the source file after it has been selected with the SYSTEM-DIALOG interface.

FACT(s) (Environment):

The Windows client being used is Western European, but with the Supplemental language support for Thai checked ON in the Regional settings.
OpenEdge 10.x
Windows

CAUSE:

The problem here is that the Win32 Progress client does not support Unicode file names. With the UTF-8 client, the file name has been constructed using multi byte characters and subsequently when an attempt is made to find the file with OS-COPY, it fails.

FIX:

Option #1
As a work around, convert the file name to use a Thai code page. This will then copy the file successfully. Although in a Western European Windows client the fille name will not look correct. However, on Windows configured Thai clients the file does appear correctly.

For example:

c_target =codepage-convert(c_utf8Target,"620-2533","utf-8").
c_source =codepage-convert(c_utf8Source,"620-2533","utf-8").

OS-COPY VALUE(c_source) VALUE(c_target).

Another alternative would be to use the Thai 620-2533 code page instead of UTF-8. This also works correctly.


Option #2
For OpenEdge 10.2x on Windows, it is possible to use .NET System.IO.File class to copy the file. This operation is dependent upon an appropriate -cpinternal setting for the session (UTF-8 or correct code page for characters used in the filename).

/* Example code */
USING System.IO.*.

DEFINE VARIABLE cFilePath AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFileName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cNewFilePath AS CHARACTER NO-UNDO.

SYSTEM-DIALOG GET-FILE cFilePath.

ASSIGN cFileName = SUBSTRING(cFilePath,R-INDEX(cFilePath,"\") + 1)
cNewFilePath = "C:\temp\" + cFileName.

/* Ensure that the target does not exist */
System.IO.File:DELETE(cNewFilePath).

/* Copy file */
System.IO.File:COPY(cFilePath,cNewFilePath).