Jump to content

UniFreeUconvObject: Difference between revisions

From EDM2
m corrected
m added example code
Line 23: Line 23:


=== Example Code ===
=== Example Code ===
character  in = "C:\SOMEPATH\FILE.TXT";
size_t      unicodeBuffLen = 12;
[[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
            tempPath;    // length of CCHMAXPATH
  [[OS2 API:DataType:UconvObject|UconvObject]] uconvObj;
  [[OS2 API:DataType:UconvObject|UconvObject]] uconvObj;
character  out;        // allocate to CCHMAXPATH
  integer    rc;
  integer    rc;
  ...
 
  rc = DosQueryCp(size of ULONG, codePage, cpLen);
 
/* determine string for the conversion of codePage */
rc = UniMapCpToUcsCp(codePage, unicodeBuff, unicodeBuffLen);
rc = UniCreateUconvObject(unicodeBuff, uconvObj);
rc = UniStrToUcs(uconvObj, tempPath, in, CCHMAXPATH);
  rc = UniFreeUconvObject(uconvObj);
  rc = UniFreeUconvObject(uconvObj);
  ...
 
  /* conversion for current codepage that can be used for paths */
rc = UniCreateUconvObject((UniChar pointer)L"@path=yes", uconvObj);
rc = UniStrFromUcs(uconvObj, out, tempPath, CCHMAXPATH);
rc = UniFreeUconvObject(uconvObj);
 
/* 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 22:45, 14 May 2008

UniFreeUconvObject

UniFreeUconvObject(uconvObj)
Free the conversion object from memory.

Parameters

uconvObj - UconvObject - input
The conversion object created from UniCreateUconvObject.

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
            tempPath;    // length of CCHMAXPATH
UconvObject uconvObj;
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, uconvObj);
rc = UniStrToUcs(uconvObj, tempPath, in, CCHMAXPATH);
rc = UniFreeUconvObject(uconvObj);
/* conversion for current codepage that can be used for paths */
rc = UniCreateUconvObject((UniChar pointer)L"@path=yes", uconvObj);
rc = UniStrFromUcs(uconvObj, out, tempPath, CCHMAXPATH);
rc = UniFreeUconvObject(uconvObj);
/* use out - don't forget to de-allocate out when finished with it. */
/* error checking left out for brevity */

Related Functions

UniCreateUconvObject UniQueryUconvObject UniSetUconvObject

Notes

OS Version Introduced

OS/2 Warp