uninp2loc

Converts a string from Unicode to the local display's code page, tracking how much of the source string was consumed.

Library:LibC
Service:Characters and Strings

Syntax

  #include <unilib.h> 
   
  int uninp2loc (
     UniRuleTable_t   table,
     char           **target,
     size_t          *destLen,
     unicode_t      **source,
     size_t           srcLen,
     char             noMapCh,
     int              noMapFlag );
  

Parameters

table

(IN) Specifies the table to use in the conversion. To use the host's default code page, specify UNI_LOCAL_DEFAULT. Otherwise, specify the value returned from the UniGetTable function.

target

(OUT) Points to the null terminator after the last converted character in the string.

destLen

(IN/OUT) Points to the maximum number of bytes that the destination string can hold when the function is called. When the function returns, it contains the number of bytes in the converted string.

source

(IN) Points to the next character in the source string to be converted or to the null terminator if at the end of the string.

srcLen

(IN) Specifies the number of Unicode characters in the source string.

noMapCh

(IN) Specifies an arbitrary character to be used in place of a source character for which no mapping can be found in the table. The noMapFlag parameter determines whether this character is used.

noMapFlag

(IN) Specifies whether to replace an unmappable character or simply return an error. It uses one of the following flags:

Flag

Value

Description

UNI_MAP_NO_CHAR

0

Returns the UNI_ERR_UNMAPPABLE_CHAR error code as soon as a character is found to be unmappable. The result is null-terminated at the offending position in the string.

UNI_MAP_CHAR

1

Uses the value in noMapCh for all unmappable characters.

UNI_MAP_SELF

2

Uses the source character. In many cases this does not result in anything useful.

Return Values

If successful, returns 0. Otherwise, returns a negative error code:

Decimal

Name

Description

-500

UNI_ERR_TOO_FEW_BYTES

The specified size for the target string is too small.

-532

UNI_ERR_UNMAPPABLE_CHAR

A character in the source is unmappable.

Remarks

The uninp2loc function null terminates the target string, adding the termination if the source string does not contain it

See Also