FreeRDP
unicode_builtin.c File Reference
#include <winpr/wtypes.h>
#include <winpr/string.h>
#include <winpr/assert.h>
#include "unicode.h"
#include "../log.h"

Macros

#define TAG   WINPR_TAG("unicode")
 
#define UNI_REPLACEMENT_CHAR   (uint32_t)0x0000FFFD
 
#define UNI_MAX_BMP   (uint32_t)0x0000FFFF
 
#define UNI_MAX_UTF16   (uint32_t)0x0010FFFF
 
#define UNI_MAX_UTF32   (uint32_t)0x7FFFFFFF
 
#define UNI_MAX_LEGAL_UTF32   (uint32_t)0x0010FFFF
 
#define UNI_SUR_HIGH_START   (uint32_t)0xD800
 
#define UNI_SUR_HIGH_END   (uint32_t)0xDBFF
 
#define UNI_SUR_LOW_START   (uint32_t)0xDC00
 
#define UNI_SUR_LOW_END   (uint32_t)0xDFFF
 

Enumerations

enum  ConversionResult { conversionOK , sourceExhausted , targetExhausted , sourceIllegal }
 
enum  ConversionFlags { strictConversion = 0 , lenientConversion }
 

Functions

static ConversionResult winpr_ConvertUTF16toUTF8_Internal (const uint16_t **sourceStart, const uint16_t *sourceEnd, uint8_t **targetStart, uint8_t *targetEnd, ConversionFlags flags)
 
static bool isLegalUTF8 (const uint8_t *source, int length)
 
static ConversionResult winpr_ConvertUTF8toUTF16_Internal (const uint8_t **sourceStart, const uint8_t *sourceEnd, uint16_t **targetStart, uint16_t *targetEnd, ConversionFlags flags)
 
static int winpr_ConvertUTF8toUTF16 (const uint8_t *src, int cchSrc, uint16_t *dst, int cchDst)
 
static int winpr_ConvertUTF16toUTF8 (const uint16_t *src, int cchSrc, uint8_t *dst, int cchDst)
 
int int_MultiByteToWideChar (UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cbMultiByte, LPWSTR lpWideCharStr, int cchWideChar)
 
int int_WideCharToMultiByte (UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar)
 

Variables

static const int halfShift = 10
 
static const uint32_t halfBase = 0x0010000UL
 
static const uint32_t halfMask = 0x3FFUL
 
static const char trailingBytesForUTF8 [256]
 
static const uint32_t offsetsFromUTF8 [6]
 
static const uint8_t firstByteMark [7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }
 

Macro Definition Documentation

◆ TAG

#define TAG   WINPR_TAG("unicode")

◆ UNI_MAX_BMP

#define UNI_MAX_BMP   (uint32_t)0x0000FFFF

◆ UNI_MAX_LEGAL_UTF32

#define UNI_MAX_LEGAL_UTF32   (uint32_t)0x0010FFFF

◆ UNI_MAX_UTF16

#define UNI_MAX_UTF16   (uint32_t)0x0010FFFF

◆ UNI_MAX_UTF32

#define UNI_MAX_UTF32   (uint32_t)0x7FFFFFFF

◆ UNI_REPLACEMENT_CHAR

#define UNI_REPLACEMENT_CHAR   (uint32_t)0x0000FFFD

◆ UNI_SUR_HIGH_END

#define UNI_SUR_HIGH_END   (uint32_t)0xDBFF

◆ UNI_SUR_HIGH_START

#define UNI_SUR_HIGH_START   (uint32_t)0xD800

◆ UNI_SUR_LOW_END

#define UNI_SUR_LOW_END   (uint32_t)0xDFFF

◆ UNI_SUR_LOW_START

#define UNI_SUR_LOW_START   (uint32_t)0xDC00

Enumeration Type Documentation

◆ ConversionFlags

Enumerator
strictConversion 
lenientConversion 

◆ ConversionResult

Enumerator
conversionOK 
sourceExhausted 
targetExhausted 
sourceIllegal 

Function Documentation

◆ int_MultiByteToWideChar()

int int_MultiByteToWideChar ( UINT  CodePage,
DWORD  dwFlags,
LPCSTR  lpMultiByteStr,
int  cbMultiByte,
LPWSTR  lpWideCharStr,
int  cchWideChar 
)

WinPR: Windows Portable Runtime Unicode Conversion (CRT)

Copyright 2022 Armin Novak anova.nosp@m.k@th.nosp@m.incas.nosp@m.t.co.nosp@m.m Copyright 2022 Thincast Technologies GmbH

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Here is the call graph for this function:

◆ int_WideCharToMultiByte()

int int_WideCharToMultiByte ( UINT  CodePage,
DWORD  dwFlags,
LPCWSTR  lpWideCharStr,
int  cchWideChar,
LPSTR  lpMultiByteStr,
int  cbMultiByte,
LPCSTR  lpDefaultChar,
LPBOOL  lpUsedDefaultChar 
)
Here is the call graph for this function:

◆ isLegalUTF8()

static bool isLegalUTF8 ( const uint8_t *  source,
int  length 
)
static
Here is the caller graph for this function:

◆ winpr_ConvertUTF16toUTF8()

static int winpr_ConvertUTF16toUTF8 ( const uint16_t *  src,
int  cchSrc,
uint8_t *  dst,
int  cchDst 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ winpr_ConvertUTF16toUTF8_Internal()

static ConversionResult winpr_ConvertUTF16toUTF8_Internal ( const uint16_t **  sourceStart,
const uint16_t *  sourceEnd,
uint8_t **  targetStart,
uint8_t *  targetEnd,
ConversionFlags  flags 
)
static
Here is the caller graph for this function:

◆ winpr_ConvertUTF8toUTF16()

static int winpr_ConvertUTF8toUTF16 ( const uint8_t *  src,
int  cchSrc,
uint16_t *  dst,
int  cchDst 
)
static

WinPR built-in Unicode API

Here is the call graph for this function:
Here is the caller graph for this function:

◆ winpr_ConvertUTF8toUTF16_Internal()

static ConversionResult winpr_ConvertUTF8toUTF16_Internal ( const uint8_t **  sourceStart,
const uint8_t *  sourceEnd,
uint16_t **  targetStart,
uint16_t *  targetEnd,
ConversionFlags  flags 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ firstByteMark

const uint8_t firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }
static

◆ halfBase

const uint32_t halfBase = 0x0010000UL
static

◆ halfMask

const uint32_t halfMask = 0x3FFUL
static

◆ halfShift

const int halfShift = 10
static

◆ offsetsFromUTF8

const uint32_t offsetsFromUTF8[6]
static
Initial value:
= { 0x00000000UL, 0x00003080UL, 0x000E2080UL,
0x03C82080UL, 0xFA082080UL, 0x82082080UL }

◆ trailingBytesForUTF8

const char trailingBytesForUTF8[256]
static
Initial value:
= {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5
}