BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB Reference

Unicode Support

Files

file  unicode.h
 Provides Unicode conversion for Unicode OSes.
 

Macros

#define PJ_DECL_UNICODE_TEMP_BUF(var, size)
 
#define PJ_STRING_TO_NATIVE(s, buf, max)   ((char*)s)
 
#define PJ_DECL_ANSI_TEMP_BUF(buf, size)
 
#define PJ_NATIVE_TO_STRING(cs, buf, max)   ((char*)(const char*)cs)
 

Functions

wchar_t * pj_ansi_to_unicode (const char *str, int len, wchar_t *wbuf, int wbuf_count)
 
char * pj_unicode_to_ansi (const wchar_t *wstr, pj_ssize_t len, char *buf, int buf_size)
 

Detailed Description

Macro Definition Documentation

◆ PJ_DECL_ANSI_TEMP_BUF

#define PJ_DECL_ANSI_TEMP_BUF (   buf,
  size 
)

This macro is used to declare temporary ANSI buffer for Unicode to ANSI conversion, and should be put in declaration section of a block. When PJ_NATIVE_STRING_IS_UNICODE macro is not defined, this macro will expand to nothing.

◆ PJ_DECL_UNICODE_TEMP_BUF

#define PJ_DECL_UNICODE_TEMP_BUF (   var,
  size 
)

This macro is used to declare temporary Unicode buffer for ANSI to Unicode conversion, and should be put in declaration section of a block. When PJ_NATIVE_STRING_IS_UNICODE macro is not defined, this macro will expand to nothing.

◆ PJ_NATIVE_TO_STRING

#define PJ_NATIVE_TO_STRING (   cs,
  buf,
  max 
)    ((char*)(const char*)cs)

This macro will convert Unicode string to ANSI, when the platform's native string is Unicode (PJ_NATIVE_STRING_IS_UNICODE is non-zero).

◆ PJ_STRING_TO_NATIVE

#define PJ_STRING_TO_NATIVE (   s,
  buf,
  max 
)    ((char*)s)

This macro will convert ANSI string to native, when the platform's native string is Unicode (PJ_NATIVE_STRING_IS_UNICODE is non-zero).

Function Documentation

◆ pj_ansi_to_unicode()

wchar_t* pj_ansi_to_unicode ( const char *  str,
int  len,
wchar_t *  wbuf,
int  wbuf_count 
)

Convert ANSI strings to Unicode strings.

Parameters
strThe ANSI string to be converted.
lenThe length of the input string.
wbufBuffer to hold the Unicode string output.
wbuf_countBuffer size, in number of elements (not bytes).
Returns
The Unicode string, NULL terminated.

◆ pj_unicode_to_ansi()

char* pj_unicode_to_ansi ( const wchar_t *  wstr,
pj_ssize_t  len,
char *  buf,
int  buf_size 
)

Convert Unicode string to ANSI string.

Parameters
wstrThe Unicode string to be converted.
lenThe length of the input string.
bufBuffer to hold the ANSI string output.
buf_sizeSize of the output buffer.
Returns
The ANSI string, NULL terminated.

 


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.