XBinder  Version 2.6.x
rtxUTF8.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2018 Objective Systems, Inc.
3  *
4  * This software is furnished under a license and may be used and copied
5  * only in accordance with the terms of such license and with the
6  * inclusion of the above copyright notice. This software or any other
7  * copies thereof may not be provided or otherwise made available to any
8  * other person. No title to and ownership of the software is hereby
9  * transferred.
10  *
11  * The information in this software is subject to change without notice
12  * and should not be construed as a commitment by Objective Systems, Inc.
13  *
14  * PROPRIETARY NOTICE
15  *
16  * This software is an unpublished work subject to a confidentiality agreement
17  * and is protected by copyright and trade secret law. Unauthorized copying,
18  * redistribution or other use of this work is prohibited.
19  *
20  * The above notice of copyright on this source code product does not indicate
21  * any actual or intended publication of such source code.
22  *
23  *****************************************************************************/
28 #ifndef _RTXUTF8_H_
29 #define _RTXUTF8_H_
30 
31 #include "rtxsrc/rtxContext.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /* UTF-8 string functions */
62 EXTERNRT long rtxUTF8ToUnicode (OSCTXT* pctxt, const OSUTF8CHAR* inbuf,
63  OSUNICHAR* outbuf, size_t outbufsiz);
64 
78 EXTERNRT long rtxUTF8ToUnicode32 (OSCTXT* pctxt, const OSUTF8CHAR* inbuf,
79  OS32BITCHAR* outbuf, size_t outbufsiz);
80 
91 EXTERNRT int rtxValidateUTF8 (OSCTXT* pctxt, const OSUTF8CHAR* inbuf);
92 
102 EXTERNRT size_t rtxUTF8Len (const OSUTF8CHAR* inbuf);
103 EXTERNRT size_t rtxCalcUTF8Len (const OSUTF8CHAR* inbuf, size_t inbufBytes);
104 
112 EXTERNRT size_t rtxUTF8LenBytes (const OSUTF8CHAR* inbuf);
113 
121 EXTERNRT int rtxUTF8CharSize (OS32BITCHAR wc);
122 
133 EXTERNRT int rtxUTF8EncodeChar (OS32BITCHAR wc, OSOCTET* buf, size_t bufsiz);
134 
145 EXTERNRT int rtxUTF8DecodeChar
146 (OSCTXT* pctxt, const OSUTF8CHAR* pinbuf, int* pInsize);
147 
157 EXTERNRT OS32BITCHAR rtxUTF8CharToWC (const OSUTF8CHAR* buf, OSUINT32* len);
158 
168 EXTERNRT OSUTF8CHAR* rtxUTF8StrChr (OSUTF8CHAR* utf8str,
169  OS32BITCHAR utf8char);
170 
180 EXTERNRT OSUTF8CHAR* rtxUTF8Strdup (OSCTXT* pctxt, const OSUTF8CHAR* utf8str);
181 
193 EXTERNRT OSUTF8CHAR* rtxUTF8Strndup
194 (OSCTXT* pctxt, const OSUTF8CHAR* utf8str, size_t nbytes);
195 
207 EXTERNRT OSUTF8CHAR* rtxUTF8StrRefOrDup
208 (OSCTXT* pctxt, const OSUTF8CHAR* utf8str);
209 
217 EXTERNRT OSBOOL rtxUTF8StrEqual
218 (const OSUTF8CHAR* utf8str1, const OSUTF8CHAR* utf8str2);
219 
230 EXTERNRT OSBOOL rtxUTF8StrnEqual (const OSUTF8CHAR* utf8str1,
231  const OSUTF8CHAR* utf8str2,
232  size_t count);
233 
245 EXTERNRT int rtxUTF8Strcmp (const OSUTF8CHAR* utf8str1,
246  const OSUTF8CHAR* utf8str2);
247 
261 EXTERNRT int rtxUTF8Strncmp (const OSUTF8CHAR* utf8str1,
262  const OSUTF8CHAR* utf8str2,
263  size_t count);
274 EXTERNRT OSUTF8CHAR* rtxUTF8Strcpy
275 (OSUTF8CHAR* dest, size_t bufsiz, const OSUTF8CHAR* src);
276 
289 EXTERNRT OSUTF8CHAR* rtxUTF8Strncpy
290 (OSUTF8CHAR* dest, size_t bufsiz, const OSUTF8CHAR* src, size_t nchars);
291 
298 EXTERNRT OSUINT32 rtxUTF8StrHash (const OSUTF8CHAR* str);
299 
316 EXTERNRT const OSUTF8CHAR* rtxUTF8StrJoin
317 (OSCTXT* pctxt, const OSUTF8CHAR* str1, const OSUTF8CHAR* str2,
318  const OSUTF8CHAR* str3, const OSUTF8CHAR* str4, const OSUTF8CHAR* str5);
319 
329 EXTERNRT int rtxUTF8StrToBool (const OSUTF8CHAR* utf8str, OSBOOL* pvalue);
330 
341 EXTERNRT int rtxUTF8StrnToBool
342  (const OSUTF8CHAR* utf8str, size_t nbytes, OSBOOL* pvalue);
343 
357 EXTERNRT int rtxUTF8StrToDouble (const OSUTF8CHAR* utf8str, OSREAL* pvalue);
358 
373 EXTERNRT int rtxUTF8StrnToDouble
374  (const OSUTF8CHAR* utf8str, size_t nbytes, OSREAL* pvalue);
375 
388 EXTERNRT int rtxUTF8StrToInt (const OSUTF8CHAR* utf8str, OSINT32* pvalue);
389 
390 #define rtxUTF8StrToInt32 rtxUTF8StrToInt
391 
406 EXTERNRT int rtxUTF8StrnToInt
407  (const OSUTF8CHAR* utf8str, size_t nbytes, OSINT32* pvalue);
408 
418 EXTERNRT int rtxUTF8StrToUInt (const OSUTF8CHAR* utf8str, OSUINT32* pvalue);
419 
420 #define rtxUTF8StrToUInt32 rtxUTF8StrToUInt
421 
433 EXTERNRT int rtxUTF8StrnToUInt
434  (const OSUTF8CHAR* utf8str, size_t nbytes, OSUINT32* pvalue);
435 
445 EXTERNRT int rtxUTF8StrToSize (const OSUTF8CHAR* utf8str, size_t* pvalue);
446 
458 EXTERNRT int rtxUTF8StrnToSize
459  (const OSUTF8CHAR* utf8str, size_t nbytes, size_t* pvalue);
460 
461 #ifndef _NO_INT64_SUPPORT
462 
471 EXTERNRT int rtxUTF8StrToInt64 (const OSUTF8CHAR* utf8str, OSINT64* pvalue);
472 
484 EXTERNRT int rtxUTF8StrnToInt64
485  (const OSUTF8CHAR* utf8str, size_t nbytes, OSINT64* pvalue);
486 
496 EXTERNRT int rtxUTF8StrToUInt64 (const OSUTF8CHAR* utf8str, OSUINT64* pvalue);
497 
509 EXTERNRT int rtxUTF8StrnToUInt64
510  (const OSUTF8CHAR* utf8str, size_t nbytes, OSUINT64* pvalue);
511 
512 #endif /* _NO_INT64_SUPPORT */
513 
527 EXTERNRT int rtxUTF8ToDynUniStr
528  (OSCTXT* pctxt, const OSUTF8CHAR* utf8str,
529  const OSUNICHAR** ppdata, OSUINT32* pnchars);
530 
544 EXTERNRT int rtxUTF8ToDynUniStr32
545  (OSCTXT* pctxt, const OSUTF8CHAR* utf8str,
546  const OS32BITCHAR** ppdata, OSUINT32* pnchars);
547 
558 EXTERNRT int rtxUTF8RemoveWhiteSpace
559 (const OSUTF8CHAR* utf8instr, size_t nbytes, const OSUTF8CHAR** putf8outstr);
560 
567 #define RTUTF8STRCMPL(name,lstr) \
568 rtxUTF8Strcmp(name,(const OSUTF8CHAR*)lstr)
569 
584 EXTERNRT int rtxUTF8StrToDynHexStr
585 (OSCTXT* pctxt, const OSUTF8CHAR* utf8str, OSDynOctStr* pvalue);
586 
602 EXTERNRT int rtxUTF8StrnToDynHexStr
603 (OSCTXT* pctxt, const OSUTF8CHAR* utf8str, size_t nbytes, OSDynOctStr* pvalue);
604 
620 EXTERNRT int rtxUTF8StrToNamedBits (OSCTXT* pctxt, const OSUTF8CHAR* utf8str,
621  const OSBitMapItem* pBitMap, OSOCTET* pvalue, OSUINT32* pnbits,
622  OSUINT32 bufsize);
623 
642 EXTERNRT const OSUTF8CHAR* rtxUTF8StrNextTok
643 (OSUTF8CHAR* utf8str, OSUTF8CHAR** ppNext);
644 
645 #define OSRTCHKUTF8LEN(str,lower,upper,stat) \
646 do { size_t nchars = rtxUTF8Len (str); \
647 stat = (nchars >= lower && nchars <= upper) ? 0 : RTERR_CONSVIO; } while(0)
648 
652 #ifdef __cplusplus
653 }
654 #endif
655 
656 #endif
EXTERNRT size_t rtxUTF8LenBytes(const OSUTF8CHAR *inbuf)
This function will return the length (in bytes) of a null-terminated UTF-8 encoded string...
EXTERNRT OSUINT32 rtxUTF8StrHash(const OSUTF8CHAR *str)
This function computes a hash code for the given string value.
EXTERNRT int rtxUTF8StrnToUInt(const OSUTF8CHAR *utf8str, size_t nbytes, OSUINT32 *pvalue)
This function converts the given part of UTF-8 string to an unsigned integer value.
EXTERNRT int rtxUTF8RemoveWhiteSpace(const OSUTF8CHAR *utf8instr, size_t nbytes, const OSUTF8CHAR **putf8outstr)
This function removes leading and trailing whitespace from a string.
EXTERNRT int rtxUTF8EncodeChar(OS32BITCHAR wc, OSOCTET *buf, size_t bufsiz)
This function will convert a wide character into an encoded UTF-8 character byte string.
EXTERNRT OSUTF8CHAR * rtxUTF8StrChr(OSUTF8CHAR *utf8str, OS32BITCHAR utf8char)
This function finds a character in the given UTF-8 character string.
EXTERNRT OSBOOL rtxUTF8StrEqual(const OSUTF8CHAR *utf8str1, const OSUTF8CHAR *utf8str2)
This function compares two UTF-8 string values for equality.
EXTERNRT int rtxUTF8StrnToUInt64(const OSUTF8CHAR *utf8str, size_t nbytes, OSUINT64 *pvalue)
This function converts the given part of UTF-8 string to an unsigned 64-bit integer value...
EXTERNRT int rtxUTF8StrToInt(const OSUTF8CHAR *utf8str, OSINT32 *pvalue)
This function converts the given null-terminated UTF-8 string to an integer value.
EXTERNRT int rtxUTF8StrnToInt(const OSUTF8CHAR *utf8str, size_t nbytes, OSINT32 *pvalue)
This function converts the given part of UTF-8 string to an integer value.
EXTERNRT int rtxUTF8StrnToDouble(const OSUTF8CHAR *utf8str, size_t nbytes, OSREAL *pvalue)
This function converts the given part of UTF-8 string to a double value.
EXTERNRT int rtxUTF8DecodeChar(OSCTXT *pctxt, const OSUTF8CHAR *pinbuf, int *pInsize)
This function will convert an encoded UTF-8 character byte string into a wide character value...
EXTERNRT const OSUTF8CHAR * rtxUTF8StrJoin(OSCTXT *pctxt, const OSUTF8CHAR *str1, const OSUTF8CHAR *str2, const OSUTF8CHAR *str3, const OSUTF8CHAR *str4, const OSUTF8CHAR *str5)
This function concatanates up to five substrings together into a single string.
EXTERNRT int rtxUTF8StrnToBool(const OSUTF8CHAR *utf8str, size_t nbytes, OSBOOL *pvalue)
This function converts the given part of UTF-8 string to a boolean (true/false) value.
EXTERNRT int rtxValidateUTF8(OSCTXT *pctxt, const OSUTF8CHAR *inbuf)
This function will validate a UTF-8 encoded string to ensure that it is encoded correctly.
Dynamic binary string structure.
Definition: osSysTypes.h:250
EXTERNRT int rtxUTF8ToDynUniStr(OSCTXT *pctxt, const OSUTF8CHAR *utf8str, const OSUNICHAR **ppdata, OSUINT32 *pnchars)
This function converts the given UTF-8 string to a Unicode string (UTF-16).
Common run-time context definitions.
EXTERNRT int rtxUTF8StrToInt64(const OSUTF8CHAR *utf8str, OSINT64 *pvalue)
This function converts the given null-terminated UTF-8 string to a 64-bit integer value...
EXTERNRT OSUTF8CHAR * rtxUTF8Strdup(OSCTXT *pctxt, const OSUTF8CHAR *utf8str)
This function creates a duplicate copy of the given UTF-8 character string.
EXTERNRT OSUTF8CHAR * rtxUTF8Strncpy(OSUTF8CHAR *dest, size_t bufsiz, const OSUTF8CHAR *src, size_t nchars)
This function copies the given number of characters from a UTF-8 string to a target buffer...
EXTERNRT int rtxUTF8StrnToInt64(const OSUTF8CHAR *utf8str, size_t nbytes, OSINT64 *pvalue)
This function converts the given part of UTF-8 string to a 64-bit integer value.
EXTERNRT int rtxUTF8StrnToSize(const OSUTF8CHAR *utf8str, size_t nbytes, size_t *pvalue)
This function converts the given part of UTF-8 string to a size value (type size_t).
EXTERNRT int rtxUTF8StrToUInt(const OSUTF8CHAR *utf8str, OSUINT32 *pvalue)
This function converts the given null-terminated UTF-8 string to an unsigned integer value...
EXTERNRT long rtxUTF8ToUnicode32(OSCTXT *pctxt, const OSUTF8CHAR *inbuf, OS32BITCHAR *outbuf, size_t outbufsiz)
This function converts a UTF-8 string to a Unicode string (UTF-32).
EXTERNRT OSUTF8CHAR * rtxUTF8Strndup(OSCTXT *pctxt, const OSUTF8CHAR *utf8str, size_t nbytes)
This function creates a duplicate copy of the given UTF-8 character string.
EXTERNRT int rtxUTF8Strcmp(const OSUTF8CHAR *utf8str1, const OSUTF8CHAR *utf8str2)
This function compares two UTF-8 character strings and returns a trinary result (equal, less than, greater than).
EXTERNRT long rtxUTF8ToUnicode(OSCTXT *pctxt, const OSUTF8CHAR *inbuf, OSUNICHAR *outbuf, size_t outbufsiz)
This function converts a UTF-8 string to a Unicode string (UTF-16).
EXTERNRT OSUTF8CHAR * rtxUTF8StrRefOrDup(OSCTXT *pctxt, const OSUTF8CHAR *utf8str)
This function check to see if the given UTF8 string pointer exists on the memory heap.
EXTERNRT size_t rtxUTF8Len(const OSUTF8CHAR *inbuf)
This function will return the length (in characters) of a null-terminated UTF-8 encoded string...
Named bit in a bit map.
Definition: osSysTypes.h:303
EXTERNRT OS32BITCHAR rtxUTF8CharToWC(const OSUTF8CHAR *buf, OSUINT32 *len)
Thia function will convert a UTF-8 encoded character value into a wide character. ...
EXTERNRT int rtxUTF8ToDynUniStr32(OSCTXT *pctxt, const OSUTF8CHAR *utf8str, const OS32BITCHAR **ppdata, OSUINT32 *pnchars)
This function converts the given UTF-8 string to a Unicode string (UTF-32).
EXTERNRT int rtxUTF8StrToSize(const OSUTF8CHAR *utf8str, size_t *pvalue)
This function converts the given null-terminated UTF-8 string to a size value (type size_t)...
EXTERNRT int rtxUTF8StrToDynHexStr(OSCTXT *pctxt, const OSUTF8CHAR *utf8str, OSDynOctStr *pvalue)
This function converts the given null-terminated UTF-8 string to a octet string value.
EXTERNRT int rtxUTF8CharSize(OS32BITCHAR wc)
This function will return the number of bytes needed to encode the given 32-bit universal character v...
EXTERNRT int rtxUTF8StrToNamedBits(OSCTXT *pctxt, const OSUTF8CHAR *utf8str, const OSBitMapItem *pBitMap, OSOCTET *pvalue, OSUINT32 *pnbits, OSUINT32 bufsize)
This function converts the given null-terminated UTF-8 string to named bit items. ...
EXTERNRT int rtxUTF8StrToDouble(const OSUTF8CHAR *utf8str, OSREAL *pvalue)
This function converts the given null-terminated UTF-8 string to a floating point (C/C++ double) valu...
EXTERNRT int rtxUTF8StrToUInt64(const OSUTF8CHAR *utf8str, OSUINT64 *pvalue)
This function converts the given null-terminated UTF-8 string to an unsigned 64-bit integer value...
Run-time context structure.
Definition: rtxContext.h:185
EXTERNRT int rtxUTF8StrnToDynHexStr(OSCTXT *pctxt, const OSUTF8CHAR *utf8str, size_t nbytes, OSDynOctStr *pvalue)
This function converts the given part of UTF-8 string to a octet string value.
EXTERNRT int rtxUTF8Strncmp(const OSUTF8CHAR *utf8str1, const OSUTF8CHAR *utf8str2, size_t count)
This function compares two UTF-8 character strings and returns a trinary result (equal, less than, greater than).
EXTERNRT const OSUTF8CHAR * rtxUTF8StrNextTok(OSUTF8CHAR *utf8str, OSUTF8CHAR **ppNext)
This function returns the next whitespace-separated token from the input string.
EXTERNRT OSBOOL rtxUTF8StrnEqual(const OSUTF8CHAR *utf8str1, const OSUTF8CHAR *utf8str2, size_t count)
This function compares two UTF-8 string values for equality.
EXTERNRT int rtxUTF8StrToBool(const OSUTF8CHAR *utf8str, OSBOOL *pvalue)
This function converts the given null-terminated UTF-8 string to a boolean (true/false) value...
EXTERNRT OSUTF8CHAR * rtxUTF8Strcpy(OSUTF8CHAR *dest, size_t bufsiz, const OSUTF8CHAR *src)
This function copies a null-terminated UTF-8 string to a target buffer.