Jump to content

UniMapCpToUcsCp: Difference between revisions

From EDM2
m formatting
m added more complete code
Line 28: Line 28:


=== Example Code ===
=== Example Code ===
  [[OS2 API:DataType:ULONG|ULONG]]   codePage;
character  in = "C:\SOMEPATH\FILE.TXT";
  [[OS2 API:DataType:UniChar|UniChar]] unicodeBuff;
  size_t unicodeBuffLen;
size_t      unicodeBuffLen = 12;
  integer rc;
  [[OS2 API:DataType:ULONG|ULONG]]       codePage;
  ...
[[OS2 API:DataType:ULONG|ULONG]]      cpLen;      // length set by [[OS2 API:DosQueryCp|DosQueryCp]]
  [[OS2 API:DataType:UniChar|UniChar]]     unicodeBuff; // length of unicodeBuffLen
  [[OS2 API:DataType:UconvObject|UconvObject]] uconv,
            tempPath;    // length of CCHMAXPATH
  character  out;         // allocate to CCHMAXPATH
  integer     rc;
 
  rc = DosQueryCp(size of ULONG, codePage, cpLen);
 
  rc = UniMapCpToUcsCp(codePage, unicodeBuff, unicodeBuffLen);
  rc = UniMapCpToUcsCp(codePage, unicodeBuff, unicodeBuffLen);
  ...
  rc = UniCreateUconvObject(unicodeBuff, uconv);
rc = UniStrToUcs(uconv, tempPath, in, CCHMAXPATH);
rc = UniFreeUconvObject(uconv);
 
/* conversion for current codepage that can be used for paths */
rc = UniCreateUconvObject((UniChar pointer)L"@path=yes", uconv);
rc = UniStrFromUcs(uconv, out, tempPath, CCHMAXPATH);
rc = UniFreeUconvObject(uconv);
 
/* use out - don't forget to de-allocate out when finished with it. */
/* error checking left out for brevity */


=== Related Functions ===
=== Related Functions ===

Revision as of 21:25, 14 May 2008

UniMapCpToUcsCp

UniMapCpToUcsCp(codePage, unicodeBuff, unicodeBuffLen)
Convert a code page string to a UCS string for input to UniCreateUconvObject.

Parameters

codePage - ULONG - input
The code page returned from DosQueryCp. If the value is zero, the current process code page is used to determine the Unicode string.
unicodeBuff - UniChar - output
The output buffer for the Unicode string.
unicodeBuffLen - (size_t) - input
The output buffer's length, in characters. Must be, at minimum, 12 Unicode characters.

Constants

None

Returns

An integer with values of:

Module

Define (C/C++)

Export name/Ordinal

Calling conversion

Cdecl32

Example Code

character   in = "C:\SOMEPATH\FILE.TXT";

size_t      unicodeBuffLen = 12;
ULONG       codePage;
ULONG       cpLen;       // length set by DosQueryCp
UniChar     unicodeBuff; // length of unicodeBuffLen
UconvObject uconv,
            tempPath;    // length of CCHMAXPATH
character   out;         // allocate to CCHMAXPATH
integer     rc;
rc = DosQueryCp(size of ULONG, codePage, cpLen);
rc = UniMapCpToUcsCp(codePage, unicodeBuff, unicodeBuffLen);
rc = UniCreateUconvObject(unicodeBuff, uconv);
rc = UniStrToUcs(uconv, tempPath, in, CCHMAXPATH);
rc = UniFreeUconvObject(uconv);
/* conversion for current codepage that can be used for paths */
rc = UniCreateUconvObject((UniChar pointer)L"@path=yes", uconv);
rc = UniStrFromUcs(uconv, out, tempPath, CCHMAXPATH);
rc = UniFreeUconvObject(uconv);
/* use out - don't forget to de-allocate out when finished with it. */
/* error checking left out for brevity */

Related Functions

UniMapCtryToLocale

Notes

OS Version Introduced

OS/2 Warp