VirtualBox

source: vbox/trunk/include/iprt/string.h@ 16027

Last change on this file since 16027 was 16027, checked in by vboxsync, 16 years ago

iprt/string.h: More ring-0 freebsd hacks.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 67.0 KB
Line 
1/** @file
2 * IPRT - String Manipluation.
3 */
4
5/*
6 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___iprt_string_h
31#define ___iprt_string_h
32
33#include <iprt/cdefs.h>
34#include <iprt/types.h>
35#include <iprt/stdarg.h>
36#include <iprt/err.h> /* for VINF_SUCCESS */
37#if defined(RT_OS_LINUX) && defined(__KERNEL__)
38# include <linux/string.h>
39#elif defined(RT_OS_FREEBSD) && defined(_KERNEL)
40 /*
41 * Kludge for the FreeBSD kernel:
42 * Some of the string.h stuff clashes with sys/libkern.h, so just wrap
43 * it up while including string.h to keep things quiet. It's nothing
44 * important that's clashing, after all. Well, with 7.x it's more
45 * essential stuff unforuntately...
46 */
47# define strdup strdup_string_h
48# define memset memset_string_h
49# define memcmp memcmp_string_h
50# define strchr strchr_string_h
51# define strrchr strrchr_string_h
52# define ffsl ffsl_string_h
53# define fls fls_string_h
54# define flsl flsl_string_h
55# include <string.h>
56# undef strdup
57# undef memset
58# undef memcmp
59# undef strchr
60# undef strrchr
61# undef ffsl
62# undef fls
63# undef flsl
64#elif defined(RT_OS_SOLARIS) && defined(_KERNEL)
65 /*
66 * Same case as with FreeBSD kernel:
67 * The string.h stuff clashes with sys/systm.h
68 * ffs = find first set bit.
69 */
70# define ffs ffs_string_h
71# include <string.h>
72# undef ffs
73# undef strpbrk
74#else
75# include <string.h>
76#endif
77
78/*
79 * Supply prototypes for standard string functions provided by
80 * IPRT instead of the operating environment.
81 */
82#if defined(RT_OS_DARWIN) && defined(KERNEL)
83__BEGIN_DECLS
84void *memchr(const void *pv, int ch, size_t cb);
85char *strpbrk(const char *pszStr, const char *pszChars);
86__END_DECLS
87#endif
88
89
90/** @defgroup grp_rt_str RTStr - String Manipulation
91 * Mostly UTF-8 related helpers where the standard string functions won't do.
92 * @ingroup grp_rt
93 * @{
94 */
95
96__BEGIN_DECLS
97
98
99/**
100 * The maximum string length.
101 */
102#define RTSTR_MAX (~(size_t)0)
103
104
105#ifdef IN_RING3
106
107/**
108 * Allocates tmp buffer, translates pszString from UTF8 to current codepage.
109 *
110 * @returns iprt status code.
111 * @param ppszString Receives pointer of allocated native CP string.
112 * The returned pointer must be freed using RTStrFree().
113 * @param pszString UTF-8 string to convert.
114 */
115RTR3DECL(int) RTStrUtf8ToCurrentCP(char **ppszString, const char *pszString);
116
117/**
118 * Allocates tmp buffer, translates pszString from current codepage to UTF-8.
119 *
120 * @returns iprt status code.
121 * @param ppszString Receives pointer of allocated UTF-8 string.
122 * The returned pointer must be freed using RTStrFree().
123 * @param pszString Native string to convert.
124 */
125RTR3DECL(int) RTStrCurrentCPToUtf8(char **ppszString, const char *pszString);
126
127#endif
128
129/**
130 * Free string allocated by any of the non-UCS-2 string functions.
131 *
132 * @returns iprt status code.
133 * @param pszString Pointer to buffer with string to free.
134 * NULL is accepted.
135 */
136RTDECL(void) RTStrFree(char *pszString);
137
138/**
139 * Allocates a new copy of the given UTF-8 string.
140 *
141 * @returns Pointer to the allocated UTF-8 string.
142 * @param pszString UTF-8 string to duplicate.
143 */
144RTDECL(char *) RTStrDup(const char *pszString);
145
146/**
147 * Allocates a new copy of the given UTF-8 string.
148 *
149 * @returns iprt status code.
150 * @param ppszString Receives pointer of the allocated UTF-8 string.
151 * The returned pointer must be freed using RTStrFree().
152 * @param pszString UTF-8 string to duplicate.
153 */
154RTDECL(int) RTStrDupEx(char **ppszString, const char *pszString);
155
156/**
157 * Validates the UTF-8 encoding of the string.
158 *
159 * @returns iprt status code.
160 * @param psz The string.
161 */
162RTDECL(int) RTStrValidateEncoding(const char *psz);
163
164/** @name Flags for RTStrValidateEncodingEx
165 */
166/** Check that the string is zero terminated within the given size.
167 * VERR_BUFFER_OVERFLOW will be returned if the check fails. */
168#define RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED RT_BIT_32(0)
169/** @} */
170
171/**
172 * Validates the UTF-8 encoding of the string.
173 *
174 * @returns iprt status code.
175 * @param psz The string.
176 * @param cch The max string length. Use RTSTR_MAX to process the entire string.
177 * @param fFlags Teserved for future. Pass 0.
178 */
179RTDECL(int) RTStrValidateEncodingEx(const char *psz, size_t cch, uint32_t fFlags);
180
181/**
182 * Checks if the UTF-8 encoding is valid.
183 *
184 * @returns true / false.
185 * @param psz The string.
186 */
187RTDECL(bool) RTStrIsValidEncoding(const char *psz);
188
189/**
190 * Gets the number of code points the string is made up of, excluding
191 * the terminator.
192 *
193 *
194 * @returns Number of code points (RTUNICP).
195 * @returns 0 if the string was incorrectly encoded.
196 * @param psz The string.
197 */
198RTDECL(size_t) RTStrUniLen(const char *psz);
199
200/**
201 * Gets the number of code points the string is made up of, excluding
202 * the terminator.
203 *
204 * This function will validate the string, and incorrectly encoded UTF-8
205 * strings will be rejected.
206 *
207 * @returns iprt status code.
208 * @param psz The string.
209 * @param cch The max string length. Use RTSTR_MAX to process the entire string.
210 * @param pcuc Where to store the code point count.
211 * This is undefined on failure.
212 */
213RTDECL(int) RTStrUniLenEx(const char *psz, size_t cch, size_t *pcuc);
214
215/**
216 * Translate a UTF-8 string into an unicode string (i.e. RTUNICPs), allocating the string buffer.
217 *
218 * @returns iprt status code.
219 * @param pszString UTF-8 string to convert.
220 * @param ppUniString Receives pointer to the allocated unicode string.
221 * The returned string must be freed using RTUniFree().
222 */
223RTDECL(int) RTStrToUni(const char *pszString, PRTUNICP *ppUniString);
224
225/**
226 * Translates pszString from UTF-8 to an array of code points, allocating the result
227 * array if requested.
228 *
229 * @returns iprt status code.
230 * @param pszString UTF-8 string to convert.
231 * @param cchString The maximum size in chars (the type) to convert. The conversion stop
232 * when it reaches cchString or the string terminator ('\\0').
233 * Use RTSTR_MAX to translate the entire string.
234 * @param ppaCps If cCps is non-zero, this must either be pointing to pointer to
235 * a buffer of the specified size, or pointer to a NULL pointer.
236 * If *ppusz is NULL or cCps is zero a buffer of at least cCps items
237 * will be allocated to hold the translated string.
238 * If a buffer was requirest it must be freed using RTUtf16Free().
239 * @param cCps The number of code points in the unicode string. This includes the terminator.
240 * @param pcCps Where to store the length of the translated string. (Optional)
241 * This field will be updated even on failure, however the value is only
242 * specified for the following two error codes. On VERR_BUFFER_OVERFLOW
243 * and VERR_NO_STR_MEMORY it contains the required buffer space.
244 */
245RTDECL(int) RTStrToUniEx(const char *pszString, size_t cchString, PRTUNICP *ppaCps, size_t cCps, size_t *pcCps);
246
247/**
248 * Calculates the length of the string in RTUTF16 items.
249 *
250 * This function will validate the string, and incorrectly encoded UTF-8
251 * strings will be rejected. The primary purpose of this function is to
252 * help allocate buffers for RTStrToUtf16Ex of the correct size. For most
253 * other puroses RTStrCalcUtf16LenEx() should be used.
254 *
255 * @returns Number of RTUTF16 items.
256 * @returns 0 if the string was incorrectly encoded.
257 * @param psz The string.
258 */
259RTDECL(size_t) RTStrCalcUtf16Len(const char *psz);
260
261/**
262 * Calculates the length of the string in RTUTF16 items.
263 *
264 * This function will validate the string, and incorrectly encoded UTF-8
265 * strings will be rejected.
266 *
267 * @returns iprt status code.
268 * @param psz The string.
269 * @param cch The max string length. Use RTSTR_MAX to process the entire string.
270 * @param pcwc Where to store the string length. Optional.
271 * This is undefined on failure.
272 */
273RTDECL(int) RTStrCalcUtf16LenEx(const char *psz, size_t cch, size_t *pcwc);
274
275/**
276 * Translate a UTF-8 string into a UTF-16 allocating the result buffer.
277 *
278 * @returns iprt status code.
279 * @param pszString UTF-8 string to convert.
280 * @param ppwszString Receives pointer to the allocated UTF-16 string.
281 * The returned string must be freed using RTUtf16Free().
282 */
283RTDECL(int) RTStrToUtf16(const char *pszString, PRTUTF16 *ppwszString);
284
285/**
286 * Translates pszString from UTF-8 to UTF-16, allocating the result buffer if requested.
287 *
288 * @returns iprt status code.
289 * @param pszString UTF-8 string to convert.
290 * @param cchString The maximum size in chars (the type) to convert. The conversion stop
291 * when it reaches cchString or the string terminator ('\\0').
292 * Use RTSTR_MAX to translate the entire string.
293 * @param ppwsz If cwc is non-zero, this must either be pointing to pointer to
294 * a buffer of the specified size, or pointer to a NULL pointer.
295 * If *ppwsz is NULL or cwc is zero a buffer of at least cwc items
296 * will be allocated to hold the translated string.
297 * If a buffer was requirest it must be freed using RTUtf16Free().
298 * @param cwc The buffer size in RTUTF16s. This includes the terminator.
299 * @param pcwc Where to store the length of the translated string. (Optional)
300 * This field will be updated even on failure, however the value is only
301 * specified for the following two error codes. On VERR_BUFFER_OVERFLOW
302 * and VERR_NO_STR_MEMORY it contains the required buffer space.
303 */
304RTDECL(int) RTStrToUtf16Ex(const char *pszString, size_t cchString, PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc);
305
306
307/**
308 * Get the unicode code point at the given string position.
309 *
310 * @returns unicode code point.
311 * @returns RTUNICP_INVALID if the encoding is invalid.
312 * @param psz The string.
313 */
314RTDECL(RTUNICP) RTStrGetCpInternal(const char *psz);
315
316/**
317 * Get the unicode code point at the given string position.
318 *
319 * @returns iprt status code
320 * @returns VERR_INVALID_UTF8_ENCODING if the encoding is invalid.
321 * @param ppsz The string.
322 * @param pCp Where to store the unicode code point.
323 * Stores RTUNICP_INVALID if the encoding is invalid.
324 */
325RTDECL(int) RTStrGetCpExInternal(const char **ppsz, PRTUNICP pCp);
326
327/**
328 * Get the unicode code point at the given string position for a string of a
329 * given length.
330 *
331 * @returns iprt status code
332 * @retval VERR_INVALID_UTF8_ENCODING if the encoding is invalid.
333 * @retval VERR_END_OF_STRING if *pcch is 0. *pCp is set to RTUNICP_INVALID.
334 *
335 * @param ppsz The string.
336 * @param pcch Pointer to the length of the string. This will be
337 * decremented by the size of the code point.
338 * @param pCp Where to store the unicode code point.
339 * Stores RTUNICP_INVALID if the encoding is invalid.
340 */
341RTDECL(int) RTStrGetCpNExInternal(const char **ppsz, size_t *pcch, PRTUNICP pCp);
342
343/**
344 * Put the unicode code point at the given string position
345 * and return the pointer to the char following it.
346 *
347 * This function will not consider anything at or following the the
348 * buffer area pointed to by psz. It is therefore not suitable for
349 * inserting code points into a string, only appending/overwriting.
350 *
351 * @returns pointer to the char following the written code point.
352 * @param psz The string.
353 * @param CodePoint The code point to write.
354 * This sould not be RTUNICP_INVALID or any other charater
355 * out of the UTF-8 range.
356 *
357 * @remark This is a worker function for RTStrPutCp().
358 *
359 */
360RTDECL(char *) RTStrPutCpInternal(char *psz, RTUNICP CodePoint);
361
362/**
363 * Get the unicode code point at the given string position.
364 *
365 * @returns unicode code point.
366 * @returns RTUNICP_INVALID if the encoding is invalid.
367 * @param psz The string.
368 *
369 * @remark We optimize this operation by using an inline function for
370 * the most frequent and simplest sequence, the rest is
371 * handled by RTStrGetCpInternal().
372 */
373DECLINLINE(RTUNICP) RTStrGetCp(const char *psz)
374{
375 const unsigned char uch = *(const unsigned char *)psz;
376 if (!(uch & RT_BIT(7)))
377 return uch;
378 return RTStrGetCpInternal(psz);
379}
380
381/**
382 * Get the unicode code point at the given string position.
383 *
384 * @returns iprt status code.
385 * @param ppsz Pointer to the string pointer. This will be updated to
386 * point to the char following the current code point.
387 * @param pCp Where to store the code point.
388 * RTUNICP_INVALID is stored here on failure.
389 *
390 * @remark We optimize this operation by using an inline function for
391 * the most frequent and simplest sequence, the rest is
392 * handled by RTStrGetCpExInternal().
393 */
394DECLINLINE(int) RTStrGetCpEx(const char **ppsz, PRTUNICP pCp)
395{
396 const unsigned char uch = **(const unsigned char **)ppsz;
397 if (!(uch & RT_BIT(7)))
398 {
399 (*ppsz)++;
400 *pCp = uch;
401 return VINF_SUCCESS;
402 }
403 return RTStrGetCpExInternal(ppsz, pCp);
404}
405
406/**
407 * Get the unicode code point at the given string position for a string of a
408 * given maximum length.
409 *
410 * @returns iprt status code.
411 * @retval VERR_INVALID_UTF8_ENCODING if the encoding is invalid.
412 * @retval VERR_END_OF_STRING if *pcch is 0. *pCp is set to RTUNICP_INVALID.
413 *
414 * @param ppsz Pointer to the string pointer. This will be updated to
415 * point to the char following the current code point.
416 * @param pcch Pointer to the maximum string length. This will be
417 * decremented by the size of the code point found.
418 * @param pCp Where to store the code point.
419 * RTUNICP_INVALID is stored here on failure.
420 *
421 * @remark We optimize this operation by using an inline function for
422 * the most frequent and simplest sequence, the rest is
423 * handled by RTStrGetCpNExInternal().
424 */
425DECLINLINE(int) RTStrGetCpNEx(const char **ppsz, size_t *pcch, PRTUNICP pCp)
426{
427 if (RT_LIKELY(*pcch != 0))
428 {
429 const unsigned char uch = **(const unsigned char **)ppsz;
430 if (!(uch & RT_BIT(7)))
431 {
432 (*ppsz)++;
433 (*pcch)--;
434 *pCp = uch;
435 return VINF_SUCCESS;
436 }
437 }
438 return RTStrGetCpNExInternal(ppsz, pcch, pCp);
439}
440
441/**
442 * Put the unicode code point at the given string position
443 * and return the pointer to the char following it.
444 *
445 * This function will not consider anything at or following the the
446 * buffer area pointed to by psz. It is therefore not suitable for
447 * inserting code points into a string, only appending/overwriting.
448 *
449 * @returns pointer to the char following the written code point.
450 * @param psz The string.
451 * @param CodePoint The code point to write.
452 * This sould not be RTUNICP_INVALID or any other charater
453 * out of the UTF-8 range.
454 *
455 * @remark We optimize this operation by using an inline function for
456 * the most frequent and simplest sequence, the rest is
457 * handled by RTStrPutCpInternal().
458 */
459DECLINLINE(char *) RTStrPutCp(char *psz, RTUNICP CodePoint)
460{
461 if (CodePoint < 0x80)
462 {
463 *psz++ = (unsigned char)CodePoint;
464 return psz;
465 }
466 return RTStrPutCpInternal(psz, CodePoint);
467}
468
469/**
470 * Skips ahead, past the current code point.
471 *
472 * @returns Pointer to the char after the current code point.
473 * @param psz Pointer to the current code point.
474 * @remark This will not move the next valid code point, only past the current one.
475 */
476DECLINLINE(char *) RTStrNextCp(const char *psz)
477{
478 RTUNICP Cp;
479 RTStrGetCpEx(&psz, &Cp);
480 return (char *)psz;
481}
482
483/**
484 * Skips back to the previous code point.
485 *
486 * @returns Pointer to the char before the current code point.
487 * @returns pszStart on failure.
488 * @param pszStart Pointer to the start of the string.
489 * @param psz Pointer to the current code point.
490 */
491RTDECL(char *) RTStrPrevCp(const char *pszStart, const char *psz);
492
493
494
495#ifndef DECLARED_FNRTSTROUTPUT /* duplicated in iprt/log.h */
496#define DECLARED_FNRTSTROUTPUT
497/**
498 * Output callback.
499 *
500 * @returns number of bytes written.
501 * @param pvArg User argument.
502 * @param pachChars Pointer to an array of utf-8 characters.
503 * @param cbChars Number of bytes in the character array pointed to by pachChars.
504 */
505typedef DECLCALLBACK(size_t) FNRTSTROUTPUT(void *pvArg, const char *pachChars, size_t cbChars);
506/** Pointer to callback function. */
507typedef FNRTSTROUTPUT *PFNRTSTROUTPUT;
508#endif
509
510/** Format flag.
511 * These are used by RTStrFormat extensions and RTStrFormatNumber, mind
512 * that not all flags makes sense to both of the functions.
513 * @{ */
514#define RTSTR_F_CAPITAL 0x0001
515#define RTSTR_F_LEFT 0x0002
516#define RTSTR_F_ZEROPAD 0x0004
517#define RTSTR_F_SPECIAL 0x0008
518#define RTSTR_F_VALSIGNED 0x0010
519#define RTSTR_F_PLUS 0x0020
520#define RTSTR_F_BLANK 0x0040
521#define RTSTR_F_WIDTH 0x0080
522#define RTSTR_F_PRECISION 0x0100
523
524#define RTSTR_F_BIT_MASK 0xf800
525#define RTSTR_F_8BIT 0x0800
526#define RTSTR_F_16BIT 0x1000
527#define RTSTR_F_32BIT 0x2000
528#define RTSTR_F_64BIT 0x4000
529#define RTSTR_F_128BIT 0x8000
530/** @} */
531
532/** @def RTSTR_GET_BIT_FLAG
533 * Gets the bit flag for the specified type.
534 */
535#define RTSTR_GET_BIT_FLAG(type) \
536 ( sizeof(type) == 32 ? RTSTR_F_32BIT \
537 : sizeof(type) == 64 ? RTSTR_F_64BIT \
538 : sizeof(type) == 16 ? RTSTR_F_16BIT \
539 : sizeof(type) == 8 ? RTSTR_F_8BIT \
540 : sizeof(type) == 128? RTSTR_F_128BIT \
541 : 0)
542
543
544/**
545 * Callback to format non-standard format specifiers.
546 *
547 * @returns The number of bytes formatted.
548 * @param pvArg Formatter argument.
549 * @param pfnOutput Pointer to output function.
550 * @param pvArgOutput Argument for the output function.
551 * @param ppszFormat Pointer to the format string pointer. Advance this till the char
552 * after the format specifier.
553 * @param pArgs Pointer to the argument list. Use this to fetch the arguments.
554 * @param cchWidth Format Width. -1 if not specified.
555 * @param cchPrecision Format Precision. -1 if not specified.
556 * @param fFlags Flags (RTSTR_NTFS_*).
557 * @param chArgSize The argument size specifier, 'l' or 'L'.
558 */
559typedef DECLCALLBACK(size_t) FNSTRFORMAT(void *pvArg, PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,
560 const char **ppszFormat, va_list *pArgs, int cchWidth,
561 int cchPrecision, unsigned fFlags, char chArgSize);
562/** Pointer to a FNSTRFORMAT() function. */
563typedef FNSTRFORMAT *PFNSTRFORMAT;
564
565
566/**
567 * Partial implementation of a printf like formatter.
568 * It doesn't do everything correct, and there is no floating point support.
569 * However, it supports custom formats by the means of a format callback.
570 *
571 * @returns number of bytes formatted.
572 * @param pfnOutput Output worker.
573 * Called in two ways. Normally with a string and its length.
574 * For termination, it's called with NULL for string, 0 for length.
575 * @param pvArgOutput Argument to the output worker.
576 * @param pfnFormat Custom format worker.
577 * @param pvArgFormat Argument to the format worker.
578 * @param pszFormat Format string pointer.
579 * @param InArgs Argument list.
580 */
581RTDECL(size_t) RTStrFormatV(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, PFNSTRFORMAT pfnFormat, void *pvArgFormat, const char *pszFormat, va_list InArgs);
582
583/**
584 * Partial implementation of a printf like formatter.
585 * It doesn't do everything correct, and there is no floating point support.
586 * However, it supports custom formats by the means of a format callback.
587 *
588 * @returns number of bytes formatted.
589 * @param pfnOutput Output worker.
590 * Called in two ways. Normally with a string and its length.
591 * For termination, it's called with NULL for string, 0 for length.
592 * @param pvArgOutput Argument to the output worker.
593 * @param pfnFormat Custom format worker.
594 * @param pvArgFormat Argument to the format worker.
595 * @param pszFormat Format string.
596 * @param ... Argument list.
597 */
598RTDECL(size_t) RTStrFormat(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, PFNSTRFORMAT pfnFormat, void *pvArgFormat, const char *pszFormat, ...);
599
600/**
601 * Formats an integer number according to the parameters.
602 *
603 * @returns Length of the formatted number.
604 * @param psz Pointer to output string buffer of sufficient size.
605 * @param u64Value Value to format.
606 * @param uiBase Number representation base.
607 * @param cchWidth Width.
608 * @param cchPrecision Precision.
609 * @param fFlags Flags (NTFS_*).
610 */
611RTDECL(int) RTStrFormatNumber(char *psz, uint64_t u64Value, unsigned int uiBase, signed int cchWidth, signed int cchPrecision, unsigned int fFlags);
612
613
614/**
615 * Callback for formatting a type.
616 *
617 * This is registered using the RTStrFormatTypeRegister function and will
618 * be called during string formatting to handle the specified %R[type].
619 * The argument for this format type is assumed to be a pointer and it's
620 * passed in the @a pvValue argument.
621 *
622 * @returns Length of the formatted output.
623 * @param pfnOutput Output worker.
624 * @param pvArgOutput Argument to the output worker.
625 * @param pszType The type name.
626 * @param pvValue The argument value.
627 * @param cchWidth Width.
628 * @param cchPrecision Precision.
629 * @param fFlags Flags (NTFS_*).
630 * @param pvUser The user argument.
631 */
632typedef DECLCALLBACK(size_t) FNRTSTRFORMATTYPE(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,
633 const char *pszType, void const *pvValue,
634 int cchWidth, int cchPrecision, unsigned fFlags,
635 void *pvUser);
636/** Pointer to a FNRTSTRFORMATTYPE. */
637typedef FNRTSTRFORMATTYPE *PFNRTSTRFORMATTYPE;
638
639
640/**
641 * Register a format handler for a type.
642 *
643 * The format handler is used to handle '%R[type]' format types, where the argument
644 * in the vector is a pointer value (a bit restrictive, but keeps it simple).
645 *
646 * The caller must ensure that no other thread will be making use of any of
647 * the dynamic formatting type facilities simultaneously with this call.
648 *
649 * @returns IPRT status code.
650 * @retval VINF_SUCCESS on success.
651 * @retval VERR_ALREADY_EXISTS if the type has already been registered.
652 * @retval VERR_TOO_MANY_OPEN_FILES if all the type slots has been allocated already.
653 *
654 * @param pszType The type name.
655 * @param pfnHandler The handler address. See FNRTSTRFORMATTYPE for details.
656 * @param pvUser The user argument to pass to the handler. See RTStrFormatTypeSetUser
657 * for how to update this later.
658 */
659RTDECL(int) RTStrFormatTypeRegister(const char *pszType, PFNRTSTRFORMATTYPE pfnHandler, void *pvUser);
660
661/**
662 * Deregisters a format type.
663 *
664 * The caller must ensure that no other thread will be making use of any of
665 * the dynamic formatting type facilities simultaneously with this call.
666 *
667 * @returns IPRT status code.
668 * @retval VINF_SUCCESS on success.
669 * @retval VERR_FILE_NOT_FOUND if not found.
670 *
671 * @param pszType The type to deregister.
672 */
673RTDECL(int) RTStrFormatTypeDeregister(const char *pszType);
674
675/**
676 * Sets the user argument for a type.
677 *
678 * This can be used if a user argument needs relocating in GC.
679 *
680 * @returns IPRT status code.
681 * @retval VINF_SUCCESS on success.
682 * @retval VERR_FILE_NOT_FOUND if not found.
683 *
684 * @param pszType The type to update.
685 * @param pvUser The new user argument value.
686 */
687RTDECL(int) RTStrFormatTypeSetUser(const char *pszType, void *pvUser);
688
689
690/**
691 * String printf.
692 *
693 * @returns The length of the returned string (in pszBuffer).
694 * @param pszBuffer Output buffer.
695 * @param cchBuffer Size of the output buffer.
696 * @param pszFormat The format string.
697 * @param args The format argument.
698 */
699RTDECL(size_t) RTStrPrintfV(char *pszBuffer, size_t cchBuffer, const char *pszFormat, va_list args);
700
701/**
702 * String printf.
703 *
704 * @returns The length of the returned string (in pszBuffer).
705 * @param pszBuffer Output buffer.
706 * @param cchBuffer Size of the output buffer.
707 * @param pszFormat The format string.
708 * @param ... The format argument.
709 */
710RTDECL(size_t) RTStrPrintf(char *pszBuffer, size_t cchBuffer, const char *pszFormat, ...);
711
712
713/**
714 * String printf with custom formatting.
715 *
716 * @returns The length of the returned string (in pszBuffer).
717 * @param pfnFormat Pointer to handler function for the custom formats.
718 * @param pvArg Argument to the pfnFormat function.
719 * @param pszBuffer Output buffer.
720 * @param cchBuffer Size of the output buffer.
721 * @param pszFormat The format string.
722 * @param args The format argument.
723 */
724RTDECL(size_t) RTStrPrintfExV(PFNSTRFORMAT pfnFormat, void *pvArg, char *pszBuffer, size_t cchBuffer, const char *pszFormat, va_list args);
725
726/**
727 * String printf with custom formatting.
728 *
729 * @returns The length of the returned string (in pszBuffer).
730 * @param pfnFormat Pointer to handler function for the custom formats.
731 * @param pvArg Argument to the pfnFormat function.
732 * @param pszBuffer Output buffer.
733 * @param cchBuffer Size of the output buffer.
734 * @param pszFormat The format string.
735 * @param ... The format argument.
736 */
737RTDECL(size_t) RTStrPrintfEx(PFNSTRFORMAT pfnFormat, void *pvArg, char *pszBuffer, size_t cchBuffer, const char *pszFormat, ...);
738
739
740/**
741 * Allocating string printf.
742 *
743 * @returns The length of the string in the returned *ppszBuffer.
744 * @returns -1 on failure.
745 * @param ppszBuffer Where to store the pointer to the allocated output buffer.
746 * The buffer should be freed using RTStrFree().
747 * On failure *ppszBuffer will be set to NULL.
748 * @param pszFormat The format string.
749 * @param args The format argument.
750 */
751RTDECL(int) RTStrAPrintfV(char **ppszBuffer, const char *pszFormat, va_list args);
752
753/**
754 * Allocating string printf.
755 *
756 * @returns The length of the string in the returned *ppszBuffer.
757 * @returns -1 on failure.
758 * @param ppszBuffer Where to store the pointer to the allocated output buffer.
759 * The buffer should be freed using RTStrFree().
760 * On failure *ppszBuffer will be set to NULL.
761 * @param pszFormat The format string.
762 * @param ... The format argument.
763 */
764RTDECL(int) RTStrAPrintf(char **ppszBuffer, const char *pszFormat, ...);
765
766
767/**
768 * Strips blankspaces from both ends of the string.
769 *
770 * @returns Pointer to first non-blank char in the string.
771 * @param psz The string to strip.
772 */
773RTDECL(char *) RTStrStrip(char *psz);
774
775/**
776 * Strips blankspaces from the start of the string.
777 *
778 * @returns Pointer to first non-blank char in the string.
779 * @param psz The string to strip.
780 */
781RTDECL(char *) RTStrStripL(const char *psz);
782
783/**
784 * Strips blankspaces from the end of the string.
785 *
786 * @returns psz.
787 * @param psz The string to strip.
788 */
789RTDECL(char *) RTStrStripR(char *psz);
790
791/**
792 * Performs a case sensitive string compare between two UTF-8 strings.
793 *
794 * Encoding errors are ignored by the current implementation. So, the only
795 * difference between this and the CRT strcmp function is the handling of
796 * NULL arguments.
797 *
798 * @returns < 0 if the first string less than the second string.
799 * @returns 0 if the first string identical to the second string.
800 * @returns > 0 if the first string greater than the second string.
801 * @param psz1 First UTF-8 string. Null is allowed.
802 * @param psz2 Second UTF-8 string. Null is allowed.
803 */
804RTDECL(int) RTStrCmp(const char *psz1, const char *psz2);
805
806/**
807 * Performs a case sensitive string compare between two UTF-8 strings, given
808 * a maximum string length.
809 *
810 * Encoding errors are ignored by the current implementation. So, the only
811 * difference between this and the CRT strncmp function is the handling of
812 * NULL arguments.
813 *
814 * @returns < 0 if the first string less than the second string.
815 * @returns 0 if the first string identical to the second string.
816 * @returns > 0 if the first string greater than the second string.
817 * @param psz1 First UTF-8 string. Null is allowed.
818 * @param psz2 Second UTF-8 string. Null is allowed.
819 * @param cchMax The maximum string length
820 */
821RTDECL(int) RTStrNCmp(const char *psz1, const char *psz2, size_t cchMax);
822
823/**
824 * Performs a case insensitive string compare between two UTF-8 strings.
825 *
826 * This is a simplified compare, as only the simplified lower/upper case folding
827 * specified by the unicode specs are used. It does not consider character pairs
828 * as they are used in some languages, just simple upper & lower case compares.
829 *
830 * The result is the difference between the mismatching codepoints after they
831 * both have been lower cased.
832 *
833 * If the string encoding is invalid the function will assert (strict builds)
834 * and use RTStrCmp for the remainder of the string.
835 *
836 * @returns < 0 if the first string less than the second string.
837 * @returns 0 if the first string identical to the second string.
838 * @returns > 0 if the first string greater than the second string.
839 * @param psz1 First UTF-8 string. Null is allowed.
840 * @param psz2 Second UTF-8 string. Null is allowed.
841 */
842RTDECL(int) RTStrICmp(const char *psz1, const char *psz2);
843
844/**
845 * Performs a case insensitive string compare between two UTF-8 strings, given a
846 * maximum string length.
847 *
848 * This is a simplified compare, as only the simplified lower/upper case folding
849 * specified by the unicode specs are used. It does not consider character pairs
850 * as they are used in some languages, just simple upper & lower case compares.
851 *
852 * The result is the difference between the mismatching codepoints after they
853 * both have been lower cased.
854 *
855 * If the string encoding is invalid the function will assert (strict builds)
856 * and use RTStrCmp for the remainder of the string.
857 *
858 * @returns < 0 if the first string less than the second string.
859 * @returns 0 if the first string identical to the second string.
860 * @returns > 0 if the first string greater than the second string.
861 * @param psz1 First UTF-8 string. Null is allowed.
862 * @param psz2 Second UTF-8 string. Null is allowed.
863 * @param cchMax Maximum string length
864 */
865RTDECL(int) RTStrNICmp(const char *psz1, const char *psz2, size_t cchMax);
866
867/**
868 * Find the length of a zero-terminated byte string, given
869 * a max string length.
870 *
871 * See also RTStrNLenEx.
872 *
873 * @returns The string length or cbMax. The returned length does not include
874 * the zero terminator if it was found.
875 *
876 * @param pszString The string.
877 * @param cchMax The max string length.
878 */
879RTDECL(size_t) RTStrNLen(const char *pszString, size_t cchMax);
880
881/**
882 * Find the length of a zero-terminated byte string, given
883 * a max string length.
884 *
885 * See also RTStrNLen.
886 *
887 * @returns IPRT status code.
888 * @retval VINF_SUCCESS if the string has a length less than cchMax.
889 * @retval VERR_BUFFER_OVERFLOW if the end of the string wasn't found
890 * before cchMax was reached.
891 *
892 * @param pszString The string.
893 * @param cchMax The max string length.
894 * @param pcch Where to store the string length excluding the
895 * terminator. This is set to cchMax if the terminator
896 * isn't found.
897 */
898RTDECL(int) RTStrNLenEx(const char *pszString, size_t cchMax, size_t *pcch);
899
900/**
901 * Matches a simple string pattern.
902 *
903 * @returns true if the string matches the pattern, otherwise false.
904 *
905 * @param pszPattern The pattern. Special chars are '*' and '?', where the
906 * asterisk matches zero or more characters and question
907 * mark matches exactly one character.
908 * @param pszString The string to match against the pattern.
909 */
910RTDECL(bool) RTStrSimplePatternMatch(const char *pszPattern, const char *pszString);
911
912/**
913 * Matches a simple string pattern, neither which needs to be zero terminated.
914 *
915 * This is identical to RTStrSimplePatternMatch except that you can optionally
916 * specify the length of both the pattern and the string. The function will
917 * stop when it hits a string terminator or either of the lengths.
918 *
919 * @returns true if the string matches the pattern, otherwise false.
920 *
921 * @param pszPattern The pattern. Special chars are '*' and '?', where the
922 * asterisk matches zero or more characters and question
923 * mark matches exactly one character.
924 * @param cchPattern The pattern length. Pass RTSTR_MAX if you don't know the
925 * length and wish to stop at the string terminator.
926 * @param pszString The string to match against the pattern.
927 * @param cchString The string length. Pass RTSTR_MAX if you don't know the
928 * length and wish to match up to the string terminator.
929 */
930RTDECL(bool) RTStrSimplePatternNMatch(const char *pszPattern, size_t cchPattern,
931 const char *pszString, size_t cchString);
932
933/**
934 * Matches multiple patterns against a string.
935 *
936 * The patterns are separated by the pipe character (|).
937 *
938 * @returns true if the string matches the pattern, otherwise false.
939 *
940 * @param pszPatterns The patterns.
941 * @param cchPatterns The lengths of the patterns to use. Pass RTSTR_MAX to
942 * stop at the terminator.
943 * @param pszString The string to match against the pattern.
944 * @param cchString The string length. Pass RTSTR_MAX stop stop at the
945 * terminator.
946 * @param poffPattern Offset into the patterns string of the patttern that
947 * matched. If no match, this will be set to RTSTR_MAX.
948 * This is optional, NULL is fine.
949 */
950RTDECL(bool) RTStrSimplePatternMultiMatch(const char *pszPatterns, size_t cchPatterns,
951 const char *pszString, size_t cchString,
952 size_t *poffPattern);
953
954
955/** @defgroup rt_str_conv String To/From Number Conversions
956 * @ingroup grp_rt_str
957 * @{ */
958
959/**
960 * Converts a string representation of a number to a 64-bit unsigned number.
961 *
962 * @returns iprt status code.
963 * Warnings are used to indicate convertion problems.
964 * @retval VWRN_NUMBER_TOO_BIG
965 * @retval VWRN_NEGATIVE_UNSIGNED
966 * @retval VWRN_TRAILING_CHARS
967 * @retval VWRN_TRAILING_SPACES
968 * @retval VINF_SUCCESS
969 * @retval VERR_NO_DIGITS
970 *
971 * @param pszValue Pointer to the string value.
972 * @param ppszNext Where to store the pointer to the first char following the number. (Optional)
973 * @param uBase The base of the representation used.
974 * If 0 the function will look for known prefixes before defaulting to 10.
975 * @param pu64 Where to store the converted number. (optional)
976 */
977RTDECL(int) RTStrToUInt64Ex(const char *pszValue, char **ppszNext, unsigned uBase, uint64_t *pu64);
978
979/**
980 * Converts a string representation of a number to a 64-bit unsigned number,
981 * making sure the full string is converted.
982 *
983 * @returns iprt status code.
984 * Warnings are used to indicate convertion problems.
985 * @retval VWRN_NUMBER_TOO_BIG
986 * @retval VWRN_NEGATIVE_UNSIGNED
987 * @retval VINF_SUCCESS
988 * @retval VERR_NO_DIGITS
989 * @retval VERR_TRAILING_SPACES
990 * @retval VERR_TRAILING_CHARS
991 *
992 * @param pszValue Pointer to the string value.
993 * @param uBase The base of the representation used.
994 * If 0 the function will look for known prefixes before defaulting to 10.
995 * @param pu64 Where to store the converted number. (optional)
996 */
997RTDECL(int) RTStrToUInt64Full(const char *pszValue, unsigned uBase, uint64_t *pu64);
998
999/**
1000 * Converts a string representation of a number to a 64-bit unsigned number.
1001 * The base is guessed.
1002 *
1003 * @returns 64-bit unsigned number on success.
1004 * @returns 0 on failure.
1005 * @param pszValue Pointer to the string value.
1006 */
1007RTDECL(uint64_t) RTStrToUInt64(const char *pszValue);
1008
1009/**
1010 * Converts a string representation of a number to a 32-bit unsigned number.
1011 *
1012 * @returns iprt status code.
1013 * Warnings are used to indicate conversion problems.
1014 * @retval VWRN_NUMBER_TOO_BIG
1015 * @retval VWRN_NEGATIVE_UNSIGNED
1016 * @retval VWRN_TRAILING_CHARS
1017 * @retval VWRN_TRAILING_SPACES
1018 * @retval VINF_SUCCESS
1019 * @retval VERR_NO_DIGITS
1020 *
1021 * @param pszValue Pointer to the string value.
1022 * @param ppszNext Where to store the pointer to the first char following the number. (Optional)
1023 * @param uBase The base of the representation used.
1024 * If 0 the function will look for known prefixes before defaulting to 10.
1025 * @param pu32 Where to store the converted number. (optional)
1026 */
1027RTDECL(int) RTStrToUInt32Ex(const char *pszValue, char **ppszNext, unsigned uBase, uint32_t *pu32);
1028
1029/**
1030 * Converts a string representation of a number to a 32-bit unsigned number,
1031 * making sure the full string is converted.
1032 *
1033 * @returns iprt status code.
1034 * Warnings are used to indicate convertion problems.
1035 * @retval VWRN_NUMBER_TOO_BIG
1036 * @retval VWRN_NEGATIVE_UNSIGNED
1037 * @retval VINF_SUCCESS
1038 * @retval VERR_NO_DIGITS
1039 * @retval VERR_TRAILING_SPACES
1040 * @retval VERR_TRAILING_CHARS
1041 *
1042 * @param pszValue Pointer to the string value.
1043 * @param uBase The base of the representation used.
1044 * If 0 the function will look for known prefixes before defaulting to 10.
1045 * @param pu32 Where to store the converted number. (optional)
1046 */
1047RTDECL(int) RTStrToUInt32Full(const char *pszValue, unsigned uBase, uint32_t *pu32);
1048
1049/**
1050 * Converts a string representation of a number to a 64-bit unsigned number.
1051 * The base is guessed.
1052 *
1053 * @returns 32-bit unsigned number on success.
1054 * @returns 0 on failure.
1055 * @param pszValue Pointer to the string value.
1056 */
1057RTDECL(uint32_t) RTStrToUInt32(const char *pszValue);
1058
1059/**
1060 * Converts a string representation of a number to a 16-bit unsigned number.
1061 *
1062 * @returns iprt status code.
1063 * Warnings are used to indicate conversion problems.
1064 * @retval VWRN_NUMBER_TOO_BIG
1065 * @retval VWRN_NEGATIVE_UNSIGNED
1066 * @retval VWRN_TRAILING_CHARS
1067 * @retval VWRN_TRAILING_SPACES
1068 * @retval VINF_SUCCESS
1069 * @retval VERR_NO_DIGITS
1070 *
1071 * @param pszValue Pointer to the string value.
1072 * @param ppszNext Where to store the pointer to the first char following the number. (Optional)
1073 * @param uBase The base of the representation used.
1074 * If 0 the function will look for known prefixes before defaulting to 10.
1075 * @param pu16 Where to store the converted number. (optional)
1076 */
1077RTDECL(int) RTStrToUInt16Ex(const char *pszValue, char **ppszNext, unsigned uBase, uint16_t *pu16);
1078
1079/**
1080 * Converts a string representation of a number to a 16-bit unsigned number,
1081 * making sure the full string is converted.
1082 *
1083 * @returns iprt status code.
1084 * Warnings are used to indicate convertion problems.
1085 * @retval VWRN_NUMBER_TOO_BIG
1086 * @retval VWRN_NEGATIVE_UNSIGNED
1087 * @retval VINF_SUCCESS
1088 * @retval VERR_NO_DIGITS
1089 * @retval VERR_TRAILING_SPACES
1090 * @retval VERR_TRAILING_CHARS
1091 *
1092 * @param pszValue Pointer to the string value.
1093 * @param uBase The base of the representation used.
1094 * If 0 the function will look for known prefixes before defaulting to 10.
1095 * @param pu16 Where to store the converted number. (optional)
1096 */
1097RTDECL(int) RTStrToUInt16Full(const char *pszValue, unsigned uBase, uint16_t *pu16);
1098
1099/**
1100 * Converts a string representation of a number to a 16-bit unsigned number.
1101 * The base is guessed.
1102 *
1103 * @returns 16-bit unsigned number on success.
1104 * @returns 0 on failure.
1105 * @param pszValue Pointer to the string value.
1106 */
1107RTDECL(uint16_t) RTStrToUInt16(const char *pszValue);
1108
1109/**
1110 * Converts a string representation of a number to a 8-bit unsigned number.
1111 *
1112 * @returns iprt status code.
1113 * Warnings are used to indicate conversion problems.
1114 * @retval VWRN_NUMBER_TOO_BIG
1115 * @retval VWRN_NEGATIVE_UNSIGNED
1116 * @retval VWRN_TRAILING_CHARS
1117 * @retval VWRN_TRAILING_SPACES
1118 * @retval VINF_SUCCESS
1119 * @retval VERR_NO_DIGITS
1120 *
1121 * @param pszValue Pointer to the string value.
1122 * @param ppszNext Where to store the pointer to the first char following the number. (Optional)
1123 * @param uBase The base of the representation used.
1124 * If 0 the function will look for known prefixes before defaulting to 10.
1125 * @param pu8 Where to store the converted number. (optional)
1126 */
1127RTDECL(int) RTStrToUInt8Ex(const char *pszValue, char **ppszNext, unsigned uBase, uint8_t *pu8);
1128
1129/**
1130 * Converts a string representation of a number to a 8-bit unsigned number,
1131 * making sure the full string is converted.
1132 *
1133 * @returns iprt status code.
1134 * Warnings are used to indicate convertion problems.
1135 * @retval VWRN_NUMBER_TOO_BIG
1136 * @retval VWRN_NEGATIVE_UNSIGNED
1137 * @retval VINF_SUCCESS
1138 * @retval VERR_NO_DIGITS
1139 * @retval VERR_TRAILING_SPACES
1140 * @retval VERR_TRAILING_CHARS
1141 *
1142 * @param pszValue Pointer to the string value.
1143 * @param uBase The base of the representation used.
1144 * If 0 the function will look for known prefixes before defaulting to 10.
1145 * @param pu8 Where to store the converted number. (optional)
1146 */
1147RTDECL(int) RTStrToUInt8Full(const char *pszValue, unsigned uBase, uint8_t *pu8);
1148
1149/**
1150 * Converts a string representation of a number to a 8-bit unsigned number.
1151 * The base is guessed.
1152 *
1153 * @returns 8-bit unsigned number on success.
1154 * @returns 0 on failure.
1155 * @param pszValue Pointer to the string value.
1156 */
1157RTDECL(uint8_t) RTStrToUInt8(const char *pszValue);
1158
1159/**
1160 * Converts a string representation of a number to a 64-bit signed number.
1161 *
1162 * @returns iprt status code.
1163 * Warnings are used to indicate conversion problems.
1164 * @retval VWRN_NUMBER_TOO_BIG
1165 * @retval VWRN_TRAILING_CHARS
1166 * @retval VWRN_TRAILING_SPACES
1167 * @retval VINF_SUCCESS
1168 * @retval VERR_NO_DIGITS
1169 *
1170 * @param pszValue Pointer to the string value.
1171 * @param ppszNext Where to store the pointer to the first char following the number. (Optional)
1172 * @param uBase The base of the representation used.
1173 * If 0 the function will look for known prefixes before defaulting to 10.
1174 * @param pi64 Where to store the converted number. (optional)
1175 */
1176RTDECL(int) RTStrToInt64Ex(const char *pszValue, char **ppszNext, unsigned uBase, int64_t *pi64);
1177
1178/**
1179 * Converts a string representation of a number to a 64-bit signed number,
1180 * making sure the full string is converted.
1181 *
1182 * @returns iprt status code.
1183 * Warnings are used to indicate convertion problems.
1184 * @retval VWRN_NUMBER_TOO_BIG
1185 * @retval VINF_SUCCESS
1186 * @retval VERR_TRAILING_CHARS
1187 * @retval VERR_TRAILING_SPACES
1188 * @retval VERR_NO_DIGITS
1189 *
1190 * @param pszValue Pointer to the string value.
1191 * @param uBase The base of the representation used.
1192 * If 0 the function will look for known prefixes before defaulting to 10.
1193 * @param pi64 Where to store the converted number. (optional)
1194 */
1195RTDECL(int) RTStrToInt64Full(const char *pszValue, unsigned uBase, int64_t *pi64);
1196
1197/**
1198 * Converts a string representation of a number to a 64-bit signed number.
1199 * The base is guessed.
1200 *
1201 * @returns 64-bit signed number on success.
1202 * @returns 0 on failure.
1203 * @param pszValue Pointer to the string value.
1204 */
1205RTDECL(int64_t) RTStrToInt64(const char *pszValue);
1206
1207/**
1208 * Converts a string representation of a number to a 32-bit signed number.
1209 *
1210 * @returns iprt status code.
1211 * Warnings are used to indicate conversion problems.
1212 * @retval VWRN_NUMBER_TOO_BIG
1213 * @retval VWRN_TRAILING_CHARS
1214 * @retval VWRN_TRAILING_SPACES
1215 * @retval VINF_SUCCESS
1216 * @retval VERR_NO_DIGITS
1217 *
1218 * @param pszValue Pointer to the string value.
1219 * @param ppszNext Where to store the pointer to the first char following the number. (Optional)
1220 * @param uBase The base of the representation used.
1221 * If 0 the function will look for known prefixes before defaulting to 10.
1222 * @param pi32 Where to store the converted number. (optional)
1223 */
1224RTDECL(int) RTStrToInt32Ex(const char *pszValue, char **ppszNext, unsigned uBase, int32_t *pi32);
1225
1226/**
1227 * Converts a string representation of a number to a 32-bit signed number,
1228 * making sure the full string is converted.
1229 *
1230 * @returns iprt status code.
1231 * Warnings are used to indicate convertion problems.
1232 * @retval VWRN_NUMBER_TOO_BIG
1233 * @retval VINF_SUCCESS
1234 * @retval VERR_TRAILING_CHARS
1235 * @retval VERR_TRAILING_SPACES
1236 * @retval VERR_NO_DIGITS
1237 *
1238 * @param pszValue Pointer to the string value.
1239 * @param uBase The base of the representation used.
1240 * If 0 the function will look for known prefixes before defaulting to 10.
1241 * @param pi32 Where to store the converted number. (optional)
1242 */
1243RTDECL(int) RTStrToInt32Full(const char *pszValue, unsigned uBase, int32_t *pi32);
1244
1245/**
1246 * Converts a string representation of a number to a 32-bit signed number.
1247 * The base is guessed.
1248 *
1249 * @returns 32-bit signed number on success.
1250 * @returns 0 on failure.
1251 * @param pszValue Pointer to the string value.
1252 */
1253RTDECL(int32_t) RTStrToInt32(const char *pszValue);
1254
1255/**
1256 * Converts a string representation of a number to a 16-bit signed number.
1257 *
1258 * @returns iprt status code.
1259 * Warnings are used to indicate conversion problems.
1260 * @retval VWRN_NUMBER_TOO_BIG
1261 * @retval VWRN_TRAILING_CHARS
1262 * @retval VWRN_TRAILING_SPACES
1263 * @retval VINF_SUCCESS
1264 * @retval VERR_NO_DIGITS
1265 *
1266 * @param pszValue Pointer to the string value.
1267 * @param ppszNext Where to store the pointer to the first char following the number. (Optional)
1268 * @param uBase The base of the representation used.
1269 * If 0 the function will look for known prefixes before defaulting to 10.
1270 * @param pi16 Where to store the converted number. (optional)
1271 */
1272RTDECL(int) RTStrToInt16Ex(const char *pszValue, char **ppszNext, unsigned uBase, int16_t *pi16);
1273
1274/**
1275 * Converts a string representation of a number to a 16-bit signed number,
1276 * making sure the full string is converted.
1277 *
1278 * @returns iprt status code.
1279 * Warnings are used to indicate convertion problems.
1280 * @retval VWRN_NUMBER_TOO_BIG
1281 * @retval VINF_SUCCESS
1282 * @retval VERR_TRAILING_CHARS
1283 * @retval VERR_TRAILING_SPACES
1284 * @retval VERR_NO_DIGITS
1285 *
1286 * @param pszValue Pointer to the string value.
1287 * @param uBase The base of the representation used.
1288 * If 0 the function will look for known prefixes before defaulting to 10.
1289 * @param pi16 Where to store the converted number. (optional)
1290 */
1291RTDECL(int) RTStrToInt16Full(const char *pszValue, unsigned uBase, int16_t *pi16);
1292
1293/**
1294 * Converts a string representation of a number to a 16-bit signed number.
1295 * The base is guessed.
1296 *
1297 * @returns 16-bit signed number on success.
1298 * @returns 0 on failure.
1299 * @param pszValue Pointer to the string value.
1300 */
1301RTDECL(int16_t) RTStrToInt16(const char *pszValue);
1302
1303/**
1304 * Converts a string representation of a number to a 8-bit signed number.
1305 *
1306 * @returns iprt status code.
1307 * Warnings are used to indicate conversion problems.
1308 * @retval VWRN_NUMBER_TOO_BIG
1309 * @retval VWRN_TRAILING_CHARS
1310 * @retval VWRN_TRAILING_SPACES
1311 * @retval VINF_SUCCESS
1312 * @retval VERR_NO_DIGITS
1313 *
1314 * @param pszValue Pointer to the string value.
1315 * @param ppszNext Where to store the pointer to the first char following the number. (Optional)
1316 * @param uBase The base of the representation used.
1317 * If 0 the function will look for known prefixes before defaulting to 10.
1318 * @param pi8 Where to store the converted number. (optional)
1319 */
1320RTDECL(int) RTStrToInt8Ex(const char *pszValue, char **ppszNext, unsigned uBase, int8_t *pi8);
1321
1322/**
1323 * Converts a string representation of a number to a 8-bit signed number,
1324 * making sure the full string is converted.
1325 *
1326 * @returns iprt status code.
1327 * Warnings are used to indicate convertion problems.
1328 * @retval VWRN_NUMBER_TOO_BIG
1329 * @retval VINF_SUCCESS
1330 * @retval VERR_TRAILING_CHARS
1331 * @retval VERR_TRAILING_SPACES
1332 * @retval VERR_NO_DIGITS
1333 *
1334 * @param pszValue Pointer to the string value.
1335 * @param uBase The base of the representation used.
1336 * If 0 the function will look for known prefixes before defaulting to 10.
1337 * @param pi8 Where to store the converted number. (optional)
1338 */
1339RTDECL(int) RTStrToInt8Full(const char *pszValue, unsigned uBase, int8_t *pi8);
1340
1341/**
1342 * Converts a string representation of a number to a 8-bit signed number.
1343 * The base is guessed.
1344 *
1345 * @returns 8-bit signed number on success.
1346 * @returns 0 on failure.
1347 * @param pszValue Pointer to the string value.
1348 */
1349RTDECL(int8_t) RTStrToInt8(const char *pszValue);
1350
1351/** @} */
1352
1353
1354/** @defgroup rt_str_space Unique String Space
1355 * @ingroup grp_rt_str
1356 * @{
1357 */
1358
1359/** Pointer to a string name space container node core. */
1360typedef struct RTSTRSPACECORE *PRTSTRSPACECORE;
1361/** Pointer to a pointer to a string name space container node core. */
1362typedef PRTSTRSPACECORE *PPRTSTRSPACECORE;
1363
1364/**
1365 * String name space container node core.
1366 */
1367typedef struct RTSTRSPACECORE
1368{
1369 /** Hash key. Don't touch. */
1370 uint32_t Key;
1371 /** Pointer to the left leaf node. Don't touch. */
1372 PRTSTRSPACECORE pLeft;
1373 /** Pointer to the left rigth node. Don't touch. */
1374 PRTSTRSPACECORE pRight;
1375 /** Pointer to the list of string with the same key. Don't touch. */
1376 PRTSTRSPACECORE pList;
1377 /** Height of this tree: max(heigth(left), heigth(right)) + 1. Don't touch */
1378 unsigned char uchHeight;
1379 /** The string length. Read only! */
1380 size_t cchString;
1381 /** Pointer to the string. Read only! */
1382 const char * pszString;
1383} RTSTRSPACECORE;
1384
1385/** String space. (Initialize with NULL.) */
1386typedef PRTSTRSPACECORE RTSTRSPACE;
1387/** Pointer to a string space. */
1388typedef PPRTSTRSPACECORE PRTSTRSPACE;
1389
1390
1391/**
1392 * Inserts a string into a unique string space.
1393 *
1394 * @returns true on success.
1395 * @returns false if the string collieded with an existing string.
1396 * @param pStrSpace The space to insert it into.
1397 * @param pStr The string node.
1398 */
1399RTDECL(bool) RTStrSpaceInsert(PRTSTRSPACE pStrSpace, PRTSTRSPACECORE pStr);
1400
1401/**
1402 * Removes a string from a unique string space.
1403 *
1404 * @returns Pointer to the removed string node.
1405 * @returns NULL if the string was not found in the string space.
1406 * @param pStrSpace The space to insert it into.
1407 * @param pszString The string to remove.
1408 */
1409RTDECL(PRTSTRSPACECORE) RTStrSpaceRemove(PRTSTRSPACE pStrSpace, const char *pszString);
1410
1411/**
1412 * Gets a string from a unique string space.
1413 *
1414 * @returns Pointer to the string node.
1415 * @returns NULL if the string was not found in the string space.
1416 * @param pStrSpace The space to insert it into.
1417 * @param pszString The string to get.
1418 */
1419RTDECL(PRTSTRSPACECORE) RTStrSpaceGet(PRTSTRSPACE pStrSpace, const char *pszString);
1420
1421/**
1422 * Callback function for RTStrSpaceEnumerate() and RTStrSpaceDestroy().
1423 *
1424 * @returns 0 on continue.
1425 * @returns Non-zero to aborts the operation.
1426 * @param pStr The string node
1427 * @param pvUser The user specified argument.
1428 */
1429typedef DECLCALLBACK(int) FNRTSTRSPACECALLBACK(PRTSTRSPACECORE pStr, void *pvUser);
1430/** Pointer to callback function for RTStrSpaceEnumerate() and RTStrSpaceDestroy(). */
1431typedef FNRTSTRSPACECALLBACK *PFNRTSTRSPACECALLBACK;
1432
1433/**
1434 * Destroys the string space.
1435 * The caller supplies a callback which will be called for each of
1436 * the string nodes in for freeing their memory and other resources.
1437 *
1438 * @returns 0 or what ever non-zero return value pfnCallback returned
1439 * when aborting the destruction.
1440 * @param pStrSpace The space to insert it into.
1441 * @param pfnCallback The callback.
1442 * @param pvUser The user argument.
1443 */
1444RTDECL(int) RTStrSpaceDestroy(PRTSTRSPACE pStrSpace, PFNRTSTRSPACECALLBACK pfnCallback, void *pvUser);
1445
1446/**
1447 * Enumerates the string space.
1448 * The caller supplies a callback which will be called for each of
1449 * the string nodes.
1450 *
1451 * @returns 0 or what ever non-zero return value pfnCallback returned
1452 * when aborting the destruction.
1453 * @param pStrSpace The space to insert it into.
1454 * @param pfnCallback The callback.
1455 * @param pvUser The user argument.
1456 */
1457RTDECL(int) RTStrSpaceEnumerate(PRTSTRSPACE pStrSpace, PFNRTSTRSPACECALLBACK pfnCallback, void *pvUser);
1458
1459/** @} */
1460
1461
1462/** @defgroup rt_str_utf16 UTF-16 String Manipulation
1463 * @ingroup grp_rt_str
1464 * @{
1465 */
1466
1467/**
1468 * Free a UTF-16 string allocated by RTStrUtf8ToUtf16(), RTStrUtf8ToUtf16Ex(),
1469 * RTUtf16Dup() or RTUtf16DupEx().
1470 *
1471 * @returns iprt status code.
1472 * @param pwszString The UTF-16 string to free. NULL is accepted.
1473 */
1474RTDECL(void) RTUtf16Free(PRTUTF16 pwszString);
1475
1476/**
1477 * Allocates a new copy of the specified UTF-16 string.
1478 *
1479 * @returns Pointer to the allocated string copy. Use RTUtf16Free() to free it.
1480 * @returns NULL when out of memory.
1481 * @param pwszString UTF-16 string to duplicate.
1482 * @remark This function will not make any attempt to validate the encoding.
1483 */
1484RTDECL(PRTUTF16) RTUtf16Dup(PCRTUTF16 pwszString);
1485
1486/**
1487 * Allocates a new copy of the specified UTF-16 string.
1488 *
1489 * @returns iprt status code.
1490 * @param ppwszString Receives pointer of the allocated UTF-16 string.
1491 * The returned pointer must be freed using RTUtf16Free().
1492 * @param pwszString UTF-16 string to duplicate.
1493 * @param cwcExtra Number of extra RTUTF16 items to allocate.
1494 * @remark This function will not make any attempt to validate the encoding.
1495 */
1496RTDECL(int) RTUtf16DupEx(PRTUTF16 *ppwszString, PCRTUTF16 pwszString, size_t cwcExtra);
1497
1498/**
1499 * Returns the length of a UTF-16 string in UTF-16 characters
1500 * without trailing '\\0'.
1501 *
1502 * Surrogate pairs counts as two UTF-16 characters here. Use RTUtf16CpCnt()
1503 * to get the exact number of code points in the string.
1504 *
1505 * @returns The number of RTUTF16 items in the string.
1506 * @param pwszString Pointer the UTF-16 string.
1507 * @remark This function will not make any attempt to validate the encoding.
1508 */
1509RTDECL(size_t) RTUtf16Len(PCRTUTF16 pwszString);
1510
1511/**
1512 * Performs a case sensitive string compare between two UTF-16 strings.
1513 *
1514 * @returns < 0 if the first string less than the second string.s
1515 * @returns 0 if the first string identical to the second string.
1516 * @returns > 0 if the first string greater than the second string.
1517 * @param pwsz1 First UTF-16 string. Null is allowed.
1518 * @param pwsz2 Second UTF-16 string. Null is allowed.
1519 * @remark This function will not make any attempt to validate the encoding.
1520 */
1521RTDECL(int) RTUtf16Cmp(register PCRTUTF16 pwsz1, register PCRTUTF16 pwsz2);
1522
1523/**
1524 * Performs a case insensitive string compare between two UTF-16 strings.
1525 *
1526 * This is a simplified compare, as only the simplified lower/upper case folding
1527 * specified by the unicode specs are used. It does not consider character pairs
1528 * as they are used in some languages, just simple upper & lower case compares.
1529 *
1530 * @returns < 0 if the first string less than the second string.
1531 * @returns 0 if the first string identical to the second string.
1532 * @returns > 0 if the first string greater than the second string.
1533 * @param pwsz1 First UTF-16 string. Null is allowed.
1534 * @param pwsz2 Second UTF-16 string. Null is allowed.
1535 */
1536RTDECL(int) RTUtf16ICmp(PCRTUTF16 pwsz1, PCRTUTF16 pwsz2);
1537
1538/**
1539 * Performs a case insensitive string compare between two UTF-16 strings
1540 * using the current locale of the process (if applicable).
1541 *
1542 * This differs from RTUtf16ICmp() in that it will try, if a locale with the
1543 * required data is available, to do a correct case-insensitive compare. It
1544 * follows that it is more complex and thereby likely to be more expensive.
1545 *
1546 * @returns < 0 if the first string less than the second string.
1547 * @returns 0 if the first string identical to the second string.
1548 * @returns > 0 if the first string greater than the second string.
1549 * @param pwsz1 First UTF-16 string. Null is allowed.
1550 * @param pwsz2 Second UTF-16 string. Null is allowed.
1551 */
1552RTDECL(int) RTUtf16LocaleICmp(PCRTUTF16 pwsz1, PCRTUTF16 pwsz2);
1553
1554/**
1555 * Folds a UTF-16 string to lowercase.
1556 *
1557 * This is a very simple folding; is uses the simple lowercase
1558 * code point, it is not related to any locale just the most common
1559 * lowercase codepoint setup by the unicode specs, and it will not
1560 * create new surrogate pairs or remove existing ones.
1561 *
1562 * @returns Pointer to the passed in string.
1563 * @param pwsz The string to fold.
1564 */
1565RTDECL(PRTUTF16) RTUtf16ToLower(PRTUTF16 pwsz);
1566
1567/**
1568 * Folds a UTF-16 string to uppercase.
1569 *
1570 * This is a very simple folding; is uses the simple uppercase
1571 * code point, it is not related to any locale just the most common
1572 * uppercase codepoint setup by the unicode specs, and it will not
1573 * create new surrogate pairs or remove existing ones.
1574 *
1575 * @returns Pointer to the passed in string.
1576 * @param pwsz The string to fold.
1577 */
1578RTDECL(PRTUTF16) RTUtf16ToUpper(PRTUTF16 pwsz);
1579
1580/**
1581 * Translate a UTF-16 string into a UTF-8 allocating the result buffer.
1582 *
1583 * @returns iprt status code.
1584 * @param pwszString UTF-16 string to convert.
1585 * @param ppszString Receives pointer of allocated UTF-8 string.
1586 * The returned pointer must be freed using RTStrFree().
1587 */
1588RTDECL(int) RTUtf16ToUtf8(PCRTUTF16 pwszString, char **ppszString);
1589
1590/**
1591 * Translates UTF-16 to UTF-8 using buffer provided by the caller or
1592 * a fittingly sized buffer allocated by the function.
1593 *
1594 * @returns iprt status code.
1595 * @param pwszString The UTF-16 string to convert.
1596 * @param cwcString The number of RTUTF16 items to translation from pwszString.
1597 * The translate will stop when reaching cwcString or the terminator ('\\0').
1598 * Use RTSTR_MAX to translate the entire string.
1599 * @param ppsz If cch is non-zero, this must either be pointing to pointer to
1600 * a buffer of the specified size, or pointer to a NULL pointer.
1601 * If *ppsz is NULL or cch is zero a buffer of at least cch chars
1602 * will be allocated to hold the translated string.
1603 * If a buffer was requirest it must be freed using RTUtf16Free().
1604 * @param cch The buffer size in chars (the type). This includes the terminator.
1605 * @param pcch Where to store the length of the translated string. (Optional)
1606 * This field will be updated even on failure, however the value is only
1607 * specified for the following two error codes. On VERR_BUFFER_OVERFLOW
1608 * and VERR_NO_STR_MEMORY it contains the required buffer space.
1609 */
1610RTDECL(int) RTUtf16ToUtf8Ex(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch);
1611
1612/**
1613 * Calculates the length of the UTF-16 string in UTF-8 chars (bytes).
1614 *
1615 * This function will validate the string, and incorrectly encoded UTF-16
1616 * strings will be rejected. The primary purpose of this function is to
1617 * help allocate buffers for RTUtf16ToUtf8() of the correct size. For most
1618 * other puroses RTUtf16ToUtf8Ex() should be used.
1619 *
1620 * @returns Number of char (bytes).
1621 * @returns 0 if the string was incorrectly encoded.
1622 * @param pwsz The UTF-16 string.
1623 */
1624RTDECL(size_t) RTUtf16CalcUtf8Len(PCRTUTF16 pwsz);
1625
1626/**
1627 * Calculates the length of the UTF-16 string in UTF-8 chars (bytes).
1628 *
1629 * This function will validate the string, and incorrectly encoded UTF-16
1630 * strings will be rejected.
1631 *
1632 * @returns iprt status code.
1633 * @param pwsz The string.
1634 * @param cwc The max string length. Use RTSTR_MAX to process the entire string.
1635 * @param pcch Where to store the string length (in bytes). Optional.
1636 * This is undefined on failure.
1637 */
1638RTDECL(int) RTUtf16CalcUtf8LenEx(PCRTUTF16 pwsz, size_t cwc, size_t *pcch);
1639
1640/**
1641 * Get the unicode code point at the given string position.
1642 *
1643 * @returns unicode code point.
1644 * @returns RTUNICP_INVALID if the encoding is invalid.
1645 * @param pwsz The string.
1646 *
1647 * @remark This is an internal worker for RTUtf16GetCp().
1648 */
1649RTDECL(RTUNICP) RTUtf16GetCpInternal(PCRTUTF16 pwsz);
1650
1651/**
1652 * Get the unicode code point at the given string position.
1653 *
1654 * @returns iprt status code.
1655 * @param ppwsz Pointer to the string pointer. This will be updated to
1656 * point to the char following the current code point.
1657 * @param pCp Where to store the code point.
1658 * RTUNICP_INVALID is stored here on failure.
1659 *
1660 * @remark This is an internal worker for RTUtf16GetCpEx().
1661 */
1662RTDECL(int) RTUtf16GetCpExInternal(PCRTUTF16 *ppwsz, PRTUNICP pCp);
1663
1664/**
1665 * Put the unicode code point at the given string position
1666 * and return the pointer to the char following it.
1667 *
1668 * This function will not consider anything at or following the the
1669 * buffer area pointed to by pwsz. It is therefore not suitable for
1670 * inserting code points into a string, only appending/overwriting.
1671 *
1672 * @returns pointer to the char following the written code point.
1673 * @param pwsz The string.
1674 * @param CodePoint The code point to write.
1675 * This sould not be RTUNICP_INVALID or any other charater
1676 * out of the UTF-16 range.
1677 *
1678 * @remark This is an internal worker for RTUtf16GetCpEx().
1679 */
1680RTDECL(PRTUTF16) RTUtf16PutCpInternal(PRTUTF16 pwsz, RTUNICP CodePoint);
1681
1682/**
1683 * Get the unicode code point at the given string position.
1684 *
1685 * @returns unicode code point.
1686 * @returns RTUNICP_INVALID if the encoding is invalid.
1687 * @param pwsz The string.
1688 *
1689 * @remark We optimize this operation by using an inline function for
1690 * everything which isn't a surrogate pair or an endian indicator.
1691 */
1692DECLINLINE(RTUNICP) RTUtf16GetCp(PCRTUTF16 pwsz)
1693{
1694 const RTUTF16 wc = *pwsz;
1695 if (wc < 0xd800 || (wc > 0xdfff && wc < 0xfffe))
1696 return wc;
1697 return RTUtf16GetCpInternal(pwsz);
1698}
1699
1700/**
1701 * Get the unicode code point at the given string position.
1702 *
1703 * @returns iprt status code.
1704 * @param ppwsz Pointer to the string pointer. This will be updated to
1705 * point to the char following the current code point.
1706 * @param pCp Where to store the code point.
1707 * RTUNICP_INVALID is stored here on failure.
1708 *
1709 * @remark We optimize this operation by using an inline function for
1710 * everything which isn't a surrogate pair or and endian indicator.
1711 */
1712DECLINLINE(int) RTUtf16GetCpEx(PCRTUTF16 *ppwsz, PRTUNICP pCp)
1713{
1714 const RTUTF16 wc = **ppwsz;
1715 if (wc < 0xd800 || (wc > 0xdfff && wc < 0xfffe))
1716 {
1717 (*ppwsz)++;
1718 *pCp = wc;
1719 return VINF_SUCCESS;
1720 }
1721 return RTUtf16GetCpExInternal(ppwsz, pCp);
1722}
1723
1724/**
1725 * Put the unicode code point at the given string position
1726 * and return the pointer to the char following it.
1727 *
1728 * This function will not consider anything at or following the the
1729 * buffer area pointed to by pwsz. It is therefore not suitable for
1730 * inserting code points into a string, only appending/overwriting.
1731 *
1732 * @returns pointer to the char following the written code point.
1733 * @param pwsz The string.
1734 * @param CodePoint The code point to write.
1735 * This sould not be RTUNICP_INVALID or any other charater
1736 * out of the UTF-16 range.
1737 *
1738 * @remark We optimize this operation by using an inline function for
1739 * everything which isn't a surrogate pair or and endian indicator.
1740 */
1741DECLINLINE(PRTUTF16) RTUtf16PutCp(PRTUTF16 pwsz, RTUNICP CodePoint)
1742{
1743 if (CodePoint < 0xd800 || (CodePoint > 0xd800 && CodePoint < 0xfffe))
1744 {
1745 *pwsz++ = (RTUTF16)CodePoint;
1746 return pwsz;
1747 }
1748 return RTUtf16PutCpInternal(pwsz, CodePoint);
1749}
1750
1751/**
1752 * Skips ahead, past the current code point.
1753 *
1754 * @returns Pointer to the char after the current code point.
1755 * @param pwsz Pointer to the current code point.
1756 * @remark This will not move the next valid code point, only past the current one.
1757 */
1758DECLINLINE(PRTUTF16) RTUtf16NextCp(PCRTUTF16 pwsz)
1759{
1760 RTUNICP Cp;
1761 RTUtf16GetCpEx(&pwsz, &Cp);
1762 return (PRTUTF16)pwsz;
1763}
1764
1765/**
1766 * Skips backwards, to the previous code point.
1767 *
1768 * @returns Pointer to the char after the current code point.
1769 * @param pwszStart Pointer to the start of the string.
1770 * @param pwsz Pointer to the current code point.
1771 */
1772RTDECL(PRTUTF16) RTUtf16PrevCp(PCRTUTF16 pwszStart, PCRTUTF16 pwsz);
1773
1774
1775/**
1776 * Checks if the UTF-16 char is the high surrogate char (i.e.
1777 * the 1st char in the pair).
1778 *
1779 * @returns true if it is.
1780 * @returns false if it isn't.
1781 * @param wc The character to investigate.
1782 */
1783DECLINLINE(bool) RTUtf16IsHighSurrogate(RTUTF16 wc)
1784{
1785 return wc >= 0xd800 && wc <= 0xdbff;
1786}
1787
1788/**
1789 * Checks if the UTF-16 char is the low surrogate char (i.e.
1790 * the 2nd char in the pair).
1791 *
1792 * @returns true if it is.
1793 * @returns false if it isn't.
1794 * @param wc The character to investigate.
1795 */
1796DECLINLINE(bool) RTUtf16IsLowSurrogate(RTUTF16 wc)
1797{
1798 return wc >= 0xdc00 && wc <= 0xdfff;
1799}
1800
1801
1802/**
1803 * Checks if the two UTF-16 chars form a valid surrogate pair.
1804 *
1805 * @returns true if they do.
1806 * @returns false if they doesn't.
1807 * @param wcHigh The high (1st) character.
1808 * @param wcLow The low (2nd) character.
1809 */
1810DECLINLINE(bool) RTUtf16IsSurrogatePair(RTUTF16 wcHigh, RTUTF16 wcLow)
1811{
1812 return RTUtf16IsHighSurrogate(wcHigh)
1813 && RTUtf16IsLowSurrogate(wcLow);
1814}
1815
1816/** @} */
1817
1818__END_DECLS
1819
1820/** @} */
1821
1822#endif
1823
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette