Jump to content

UniMapCpToUcsCp: Difference between revisions

From EDM2
m formatting
Ak120 (talk | contribs)
mNo edit summary
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== UniMapCpToUcsCp ==
Convert a code page string to a UCS string for input to [[UniCreateUconvObject]].
; UniMapCpToUcsCp(codePage, unicodeBuff, unicodeBuffLen) : Convert a code page string to a UCS string for input to [[OS2_API:UniCreateUconvObject|UniCreateUconvObject]].
 
=== Syntax ===
UniMapCpToUcsCp(codePage, unicodeBuff, unicodeBuffLen);


=== Parameters ===
=== Parameters ===
; codePage - [[OS2 API:DataType:ULONG|ULONG]] - input : The code page returned from [[OS2 API:DosQueryCp|DosQueryCp]]. If the value is zero, the current process code page is used to determine the Unicode string.
;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 - [[OS2 API:DataType:UniChar|UniChar]] - output : The output buffer for 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.
;unicodeBuffLen - (size_t) - input : The output buffer's length, in characters.  Must be, at minimum, 12 Unicode characters.


=== Constants ===
=== Constants ===
Line 12: Line 14:
=== Returns ===
=== Returns ===
An integer with values of:
An integer with values of:
* [[OS2 API:Unicode:error#ULS_INVALID|ULS_INVALID]]
* [[Unicode Errors#ULS_INVALID|ULS_INVALID]]
* [[OS2 API:Unicode:error#ULS_NOMEMORY|ULS_NOMEMORY]]
* [[Unicode Errors#ULS_NOMEMORY|ULS_NOMEMORY]]
* [[OS2 API:Unicode:error#ULS_SUCCESS|ULS_SUCCESS]]
* [[Unicode Errors#ULS_SUCCESS|ULS_SUCCESS]]


=== Module ===
=== Calling Convention ===
[[Cdecl32]]


=== Define (C/C++) ===
=== 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
            tempPath;    // length of CCHMAXPATH
UconvObject uconv;
character  out;        // allocate to CCHMAXPATH
integer    rc;


rc = DosQueryCp(size of ULONG, codePage, cpLen);


=== Export name/Ordinal ===
/* determine string for the conversion of codePage */
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);


=== Calling conversion ===
  /* use out - don't forget to de-allocate out when finished with it. */
[[Cdecl32]]
  /* error checking left out for brevity */
 
=== Example Code ===
[[OS2 API:DataType:ULONG|ULONG]]  codePage;
[[OS2 API:DataType:UniChar|UniChar]] unicodeBuff;
size_t  unicodeBuffLen;
  integer rc;
...
  rc = UniMapCpToUcsCp(codePage, unicodeBuff, unicodeBuffLen);
...


=== Related Functions ===
=== Related Functions ===
[[OS2 API:UniMapCtryToLocale|UniMapCtryToLocale]]
*[[UniMapCtryToLocale]]
 
=== Notes ===
 


=== OS Version Introduced ===
=== OS Version Introduced ===
OS/2 Warp
OS/2 Warp
[[Category:Uni]]

Latest revision as of 18:02, 4 December 2019

Convert a code page string to a UCS string for input to UniCreateUconvObject.

Syntax

UniMapCpToUcsCp(codePage, unicodeBuff, unicodeBuffLen);

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:

Calling Convention

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
            tempPath;    // length of CCHMAXPATH
UconvObject uconv;
character   out;         // allocate to CCHMAXPATH
integer     rc;
rc = DosQueryCp(size of ULONG, codePage, cpLen);
/* determine string for the conversion of codePage */
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

OS Version Introduced

OS/2 Warp