1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 * This file is part of LibreOffice published API.
24 #ifndef INCLUDED_RTL_USTRING_H
25 #define INCLUDED_RTL_USTRING_H
27 #include "sal/config.h"
29 #include "osl/interlck.h"
30 #include "rtl/string.h"
31 #include "rtl/textenc.h"
32 #include "sal/saldllapi.h"
33 #include "sal/types.h"
39 /* ======================================================================= */
41 /** Return the length of a string.
43 The length is equal to the number of 16-bit Unicode characters in the
44 string, without the terminating NUL character.
47 a null-terminated string.
50 the length of the sequence of characters represented by this string,
51 excluding the terminating NUL character.
53 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_getLength(
54 const sal_Unicode
* str
) SAL_THROW_EXTERN_C();
56 /** Compare two strings.
58 The comparison is based on the numeric value of each character in the
59 strings and returns a value indicating their relationship. This function
60 cannot be used for language-specific sorting. Both strings must be
64 the first null-terminated string to be compared.
67 the second null-terminated string which is compared with the first one.
70 0 if both strings are equal, a value less than 0 if the first string is
71 less than the second string, and a value greater than 0 if the first
72 string is greater than the second string.
74 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_compare(
75 const sal_Unicode
* first
, const sal_Unicode
* second
) SAL_THROW_EXTERN_C();
77 /** Compare two strings.
79 The comparison is based on the numeric value of each character in the
80 strings and returns a value indicating their relationship. This function
81 cannot be used for language-specific sorting.
84 the first string to be compared. Need not be null-terminated, but must be
85 at least as long as the specified firstLen.
88 the length of the first string.
91 the second string which is compared with the first one. Need not be
92 null-terminated, but must be at least as long as the specified secondLen.
95 the length of the second string.
98 0 if both strings are equal, a value less than 0 if the first string is
99 less than the second string, and a value greater than 0 if the first
100 string is greater than the second string.
102 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_compare_WithLength(
103 const sal_Unicode
* first
, sal_Int32 firstLen
, const sal_Unicode
* second
, sal_Int32 secondLen
) SAL_THROW_EXTERN_C();
105 /** Compare two strings with a maximum count of characters.
107 The comparison is based on the numeric value of each character in the
108 strings and returns a value indicating their relationship. This function
109 cannot be used for language-specific sorting.
112 the first string to be compared. Need not be null-terminated, but must be
113 at least as long as the specified firstLen.
116 the length of the first string.
119 the second string which is compared with the first one. Need not be
120 null-terminated, but must be at least as long as the specified secondLen.
123 the length of the second string.
126 the maximum number of characters to compare. This length can be greater
127 or smaller than the lengths of the two strings.
130 0 if both substrings are equal, a value less than 0 if the first substring
131 is less than the second substring, and a value greater than 0 if the first
132 substring is greater than the second substring.
134 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_shortenedCompare_WithLength(
135 const sal_Unicode
* first
, sal_Int32 firstLen
, const sal_Unicode
* second
, sal_Int32 secondLen
, sal_Int32 shortenedLen
) SAL_THROW_EXTERN_C();
137 /** Compare two strings from back to front.
139 The comparison is based on the numeric value of each character in the
140 strings and returns a value indicating their relationship. This function
141 cannot be used for language-specific sorting.
144 the first string to be compared. Need not be null-terminated, but must be
145 at least as long as the specified firstLen.
148 the length of the first string.
151 the second string which is compared with the first one. Need not be
152 null-terminated, but must be at least as long as the specified secondLen.
155 the length of the second string.
158 0 if both strings are equal, a value less than 0 if the first string
159 compares less than the second string, and a value greater than 0 if the
160 first string compares greater than the second string.
162 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_reverseCompare_WithLength(
163 const sal_Unicode
* first
, sal_Int32 firstLen
, const sal_Unicode
* second
, sal_Int32 secondLen
) SAL_THROW_EXTERN_C();
165 /** Compare two strings from back to front for equality.
167 The comparison is based on the numeric value of each character in the
168 strings and returns 'true' if, and only if, both strings are equal.
169 This function cannot be used for language-specific sorting.
172 the first string to be compared. Need not be null-terminated, but must be
173 at least as long as the specified len.
176 the second string which is compared with the first one. Need not be
177 null-terminated, but must be at least as long as the specified len.
180 the length of both strings.
183 true if both strings are equal, false if they are not equal.
186 SAL_DLLPUBLIC sal_Bool SAL_CALL
rtl_ustr_asciil_reverseEquals_WithLength(
187 const sal_Unicode
* first
, const char * second
, sal_Int32 len
) SAL_THROW_EXTERN_C();
189 /** Compare two strings, ignoring the case of ASCII characters.
191 The comparison is based on the numeric value of each character in the
192 strings and returns a value indicating their relationship. Character
193 values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
194 and 122 (ASCII a--z). This function cannot be used for language-specific
195 sorting. Both strings must be null-terminated.
198 the first null-terminated string to be compared.
201 the second null-terminated string which is compared with the first one.
204 0 if both strings are equal, a value less than 0 if the first string is
205 less than the second string, and a value greater than 0 if the first
206 string is greater than the second string.
208 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_compareIgnoreAsciiCase(
209 const sal_Unicode
* first
, const sal_Unicode
* second
) SAL_THROW_EXTERN_C();
211 /** Compare two strings, ignoring the case of ASCII characters.
213 The comparison is based on the numeric value of each character in the
214 strings and returns a value indicating their relationship. Character
215 values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
216 and 122 (ASCII a--z). This function cannot be used for language-specific
220 the first string to be compared. Need not be null-terminated, but must be
221 at least as long as the specified firstLen.
224 the length of the first string.
227 the second string which is compared with the first one. Need not be
228 null-terminated, but must be at least as long as the specified secondLen.
231 the length of the second string.
234 0 if both strings are equal, a value less than 0 if the first string is
235 less than the second string, and a value greater than 0 if the first
236 string is greater than the second string.
238 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_compareIgnoreAsciiCase_WithLength(
239 const sal_Unicode
* first
, sal_Int32 firstLen
, const sal_Unicode
* second
, sal_Int32 secondLen
) SAL_THROW_EXTERN_C();
241 /** Compare two strings with a maximum count of characters, ignoring the case
244 The comparison is based on the numeric value of each character in the
245 strings and returns a value indicating their relationship. Character
246 values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
247 and 122 (ASCII a--z). This function cannot be used for language-specific
251 the first string to be compared. Need not be null-terminated, but must be
252 at least as long as the specified firstLen.
255 the length of the first string.
258 the second string which is compared with the first one. Need not be
259 null-terminated, but must be at least as long as the specified secondLen.
262 the length of the second string.
265 the maximum number of characters to compare. This length can be greater
266 or smaller than the lengths of the two strings.
269 0 if both substrings are equal, a value less than 0 if the first substring
270 is less than the second substring, and a value greater than 0 if the first
271 substring is greater than the second substring.
273 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength(
274 const sal_Unicode
* first
, sal_Int32 firstLen
, const sal_Unicode
* second
, sal_Int32 secondLen
, sal_Int32 shortenedLen
) SAL_THROW_EXTERN_C();
276 /** Compare two strings.
278 The comparison is based on the numeric value of each character in the
279 strings and returns a value indicating their relationship. This function
280 cannot be used for language-specific sorting. Both strings must be
283 Since this function is optimized for performance, the ASCII character
284 values are not converted in any way. The caller has to make sure that
285 all ASCII characters are in the allowed range of 0 and 127, inclusive.
288 the first null-terminated string to be compared.
291 the second null-terminated ASCII string which is compared with the first
295 0 if both substrings are equal, a value less than 0 if the first substring
296 is less than the second substring, and a value greater than 0 if the first
297 substring is greater than the second substring.
299 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_ascii_compare(
300 const sal_Unicode
* first
, const char * second
) SAL_THROW_EXTERN_C();
302 /** Compare two strings.
304 The comparison is based on the numeric value of each character in the
305 strings and returns a value indicating their relationship. This function
306 cannot be used for language-specific sorting.
308 Since this function is optimized for performance, the ASCII character
309 values are not converted in any way. The caller has to make sure that
310 all ASCII characters are in the allowed range of 0 and 127, inclusive.
313 the first string to be compared. Need not be null-terminated, but must be
314 at least as long as the specified firstLen.
317 the length of the first string.
320 the second null-terminated ASCII string which is compared with the first
324 0 if both substrings are equal, a value less than 0 if the first substring
325 is less than the second substring, and a value greater than 0 if the first
326 substring is greater than the second substring.
328 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_ascii_compare_WithLength(
329 const sal_Unicode
* first
, sal_Int32 firstLen
, const char * second
) SAL_THROW_EXTERN_C();
331 /** Compare two strings with a maximum count of characters.
333 The comparison is based on the numeric value of each character in the
334 strings and returns a value indicating their relationship. This function
335 cannot be used for language-specific sorting.
337 Since this function is optimized for performance, the ASCII character
338 values are not converted in any way. The caller has to make sure that
339 all ASCII characters are in the allowed range of 0 and 127, inclusive.
342 the first string to be compared. Need not be null-terminated, but must be
343 at least as long as the specified firstLen.
346 the length of the first string.
349 the second null-terminated ASCII string which is compared with the first
353 the maximum number of characters to compare. This length can be greater
354 or smaller than the lengths of the two strings.
357 0 if both substrings are equal, a value less than 0 if the first substring
358 is less than the second substring, and a value greater than 0 if the first
359 substring is greater than the second substring.
361 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_ascii_shortenedCompare_WithLength(
362 const sal_Unicode
* first
, sal_Int32 firstLen
, const char * second
, sal_Int32 shortenedLen
) SAL_THROW_EXTERN_C();
364 /** Compare two strings from back to front.
366 The comparison is based on the numeric value of each character in the
367 strings and returns a value indicating their relationship. This function
368 cannot be used for language-specific sorting.
370 Since this function is optimized for performance, the ASCII character
371 values are not converted in any way. The caller has to make sure that
372 all ASCII characters are in the allowed range of 0 and 127, inclusive.
375 the first string to be compared. Need not be null-terminated, but must be
376 at least as long as the specified firstLen.
379 the length of the first string.
382 the second ASCII string which is compared with the first one. Need not be
383 null-terminated, but must be at least as long as the specified secondLen.
386 the length of the second string.
389 0 if both strings are equal, a value less than 0 if the first string
390 compares less than the second string, and a value greater than 0 if the
391 first string compares greater than the second string.
393 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_asciil_reverseCompare_WithLength(
394 const sal_Unicode
* first
, sal_Int32 firstLen
, const char * second
, sal_Int32 secondLen
) SAL_THROW_EXTERN_C();
396 /** Compare two strings, ignoring the case of ASCII characters.
398 The comparison is based on the numeric value of each character in the
399 strings and returns a value indicating their relationship. Character
400 values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
401 and 122 (ASCII a--z). This function cannot be used for language-specific
402 sorting. Both strings must be null-terminated.
404 Since this function is optimized for performance, the ASCII character
405 values are not converted in any way. The caller has to make sure that
406 all ASCII characters are in the allowed range of 0 and 127, inclusive.
409 the first null-terminated string to be compared.
412 the second null-terminated ASCII string which is compared with the first
416 0 if both strings are equal, a value less than 0 if the first string is
417 less than the second string, and a value greater than 0 if the first
418 string is greater than the second string.
420 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_ascii_compareIgnoreAsciiCase(
421 const sal_Unicode
* first
, const char * second
) SAL_THROW_EXTERN_C();
423 /** Compare two strings, ignoring the case of ASCII characters.
425 The comparison is based on the numeric value of each character in the
426 strings and returns a value indicating their relationship. Character
427 values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
428 and 122 (ASCII a--z). This function cannot be used for language-specific
431 Since this function is optimized for performance, the ASCII character
432 values are not converted in any way. The caller has to make sure that
433 all ASCII characters are in the allowed range of 0 and 127, inclusive.
436 the first string to be compared. Need not be null-terminated, but must be
437 at least as long as the specified firstLen.
440 the length of the first string.
443 the second null-terminated ASCII string which is compared with the first
447 0 if both strings are equal, a value less than 0 if the first string is
448 less than the second string, and a value greater than 0 if the first
449 string is greater than the second string.
451 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength(
452 const sal_Unicode
* first
, sal_Int32 firstLen
, const char * second
) SAL_THROW_EXTERN_C();
454 /** Compare two strings, ignoring the case of ASCII characters.
456 The comparison is based on the numeric value of each character in the
457 strings and returns a value indicating their relationship. Character
458 values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
459 and 122 (ASCII a--z). This function cannot be used for language-specific
462 Since this function is optimized for performance, the ASCII character
463 values are not converted in any way. The caller has to make sure that
464 all ASCII characters are in the allowed range of 0 and 127, inclusive.
467 the first string to be compared. Need not be null-terminated, but must be
468 at least as long as the specified firstLen.
471 the length of the first string.
474 the second string which is compared with the first one. Need not be
475 null-terminated, but must be at least as long as the specified secondLen.
478 the length of the second string.
481 0 if both strings are equal, a value less than 0 if the first string is
482 less than the second string, and a value greater than 0 if the first
483 string is greater than the second string.
485 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
486 sal_Unicode
const * first
, sal_Int32 firstLen
,
487 char const * second
, sal_Int32 secondLen
) SAL_THROW_EXTERN_C();
489 /** Compare two strings with a maximum count of characters, ignoring the case
492 The comparison is based on the numeric value of each character in the
493 strings and returns a value indicating their relationship. Character
494 values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
495 and 122 (ASCII a--z). This function cannot be used for language-specific
498 Since this function is optimized for performance, the ASCII character
499 values are not converted in any way. The caller has to make sure that
500 all ASCII characters are in the allowed range of 0 and 127, inclusive.
503 the first string to be compared. Need not be null-terminated, but must be
504 at least as long as the specified firstLen.
507 the length of the first string.
510 the second null-terminated ASCII string which is compared with the first
514 the maximum number of characters to compare. This length can be greater
515 or smaller than the lengths of the two strings.
518 0 if both substrings are equal, a value less than 0 if the first substring
519 is less than the second substring, and a value greater than 0 if the first
520 substring is greater than the second substring.
522 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
523 const sal_Unicode
* first
, sal_Int32 firstLen
, const char * second
, sal_Int32 shortenedLen
) SAL_THROW_EXTERN_C();
525 /** Return a hash code for a string.
527 It is not allowed to store the hash code persistently, because later
528 versions could return other hash codes. The string must be
532 a null-terminated string.
535 a hash code for the given string.
537 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_hashCode(
538 const sal_Unicode
* str
) SAL_THROW_EXTERN_C();
540 /** Return a hash code for a string.
542 It is not allowed to store the hash code persistently, because later
543 versions could return other hash codes.
546 a string. Need not be null-terminated, but must be at least as long as
550 the length of the string.
553 a hash code for the given string.
555 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_hashCode_WithLength(
556 const sal_Unicode
* str
, sal_Int32 len
) SAL_THROW_EXTERN_C();
558 /** Search for the first occurrence of a character within a string.
560 The string must be null-terminated.
563 a null-terminated string.
566 the character to be searched for.
569 the index (starting at 0) of the first occurrence of the character in the
570 string, or -1 if the character does not occur.
572 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_indexOfChar(
573 const sal_Unicode
* str
, sal_Unicode ch
) SAL_THROW_EXTERN_C();
575 /** Search for the first occurrence of a character within a string.
578 a string. Need not be null-terminated, but must be at least as long as
582 the length of the string.
585 the character to be searched for.
588 the index (starting at 0) of the first occurrence of the character in the
589 string, or -1 if the character does not occur.
591 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_indexOfChar_WithLength(
592 const sal_Unicode
* str
, sal_Int32 len
, sal_Unicode ch
) SAL_THROW_EXTERN_C();
594 /** Search for the last occurrence of a character within a string.
596 The string must be null-terminated.
599 a null-terminated string.
602 the character to be searched for.
605 the index (starting at 0) of the last occurrence of the character in the
606 string, or -1 if the character does not occur. The returned value is
607 always smaller than the string length.
609 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_lastIndexOfChar(
610 const sal_Unicode
* str
, sal_Unicode ch
) SAL_THROW_EXTERN_C();
612 /** Search for the last occurrence of a character within a string.
615 a string. Need not be null-terminated, but must be at least as long as
619 the length of the string.
622 the character to be searched for.
625 the index (starting at 0) of the last occurrence of the character in the
626 string, or -1 if the character does not occur. The returned value is
627 always smaller than the string length.
629 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_lastIndexOfChar_WithLength(
630 const sal_Unicode
* str
, sal_Int32 len
, sal_Unicode ch
) SAL_THROW_EXTERN_C();
632 /** Search for the first occurrence of a substring within a string.
634 If subStr is empty, or both str and subStr are empty, -1 is returned.
635 Both strings must be null-terminated.
638 a null-terminated string.
641 the null-terminated substring to be searched for.
644 the index (starting at 0) of the first character of the first occurrence
645 of the substring within the string, or -1 if the substring does not occur.
647 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_indexOfStr(
648 const sal_Unicode
* str
, const sal_Unicode
* subStr
) SAL_THROW_EXTERN_C();
650 /** Search for the first occurrence of a substring within a string.
652 If subStr is empty, or both str and subStr are empty, -1 is returned.
655 a string. Need not be null-terminated, but must be at least as long as
659 the length of the string.
662 the substring to be searched for. Need not be null-terminated, but must
663 be at least as long as the specified subLen.
666 the length of the substring.
669 the index (starting at 0) of the first character of the first occurrence
670 of the substring within the string, or -1 if the substring does not occur.
672 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_indexOfStr_WithLength(
673 const sal_Unicode
* str
, sal_Int32 len
, const sal_Unicode
* subStr
, sal_Int32 subLen
) SAL_THROW_EXTERN_C();
675 /** Search for the first occurrence of an ASCII substring within a string.
678 a string. Need not be null-terminated, but must be at least as long as
682 the length of the string; must be non-negative.
685 the substring to be searched for. Need not be null-terminated, but must
686 be at least as long as the specified subLen. Must only contain characters
687 in the ASCII range 0x00--7F.
690 the length of the substring; must be non-negative.
693 the index (starting at 0) of the first character of the first occurrence
694 of the substring within the string, or -1 if the substring does not occur.
695 If subLen is zero, -1 is returned.
699 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_indexOfAscii_WithLength(
700 sal_Unicode
const * str
, sal_Int32 len
,
701 char const * subStr
, sal_Int32 subLen
) SAL_THROW_EXTERN_C();
703 /** Search for the last occurrence of a substring within a string.
705 If subStr is empty, or both str and subStr are empty, -1 is returned.
706 Both strings must be null-terminated.
709 a null-terminated string.
712 the null-terminated substring to be searched for.
715 the index (starting at 0) of the first character of the last occurrence
716 of the substring within the string, or -1 if the substring does not occur.
718 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_lastIndexOfStr(
719 const sal_Unicode
* str
, const sal_Unicode
* subStr
) SAL_THROW_EXTERN_C();
721 /** Search for the last occurrence of a substring within a string.
723 If subStr is empty, or both str and subStr are empty, -1 is returned.
726 a string. Need not be null-terminated, but must be at least as long as
730 the length of the string.
733 the substring to be searched for. Need not be null-terminated, but must
734 be at least as long as the specified subLen.
737 the length of the substring.
740 the index (starting at 0) of the first character of the first occurrence
741 of the substring within the string, or -1 if the substring does not occur.
743 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_lastIndexOfStr_WithLength(
744 const sal_Unicode
* str
, sal_Int32 len
, const sal_Unicode
* subStr
, sal_Int32 subLen
) SAL_THROW_EXTERN_C();
746 /** Search for the last occurrence of an ASCII substring within a string.
749 a string. Need not be null-terminated, but must be at least as long as
753 the length of the string; must be non-negative.
756 the substring to be searched for. Need not be null-terminated, but must
757 be at least as long as the specified subLen. Must only contain characters
758 in the ASCII range 0x00--7F.
761 the length of the substring; must be non-negative.
764 the index (starting at 0) of the first character of the last occurrence
765 of the substring within the string, or -1 if the substring does not occur.
766 If subLen is zero, -1 is returned.
770 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_lastIndexOfAscii_WithLength(
771 sal_Unicode
const * str
, sal_Int32 len
,
772 char const * subStr
, sal_Int32 subLen
) SAL_THROW_EXTERN_C();
774 /** Replace all occurrences of a single character within a string.
776 If oldChar does not occur within str, then the string is not modified.
777 The string must be null-terminated.
780 a null-terminated string.
788 SAL_DLLPUBLIC
void SAL_CALL
rtl_ustr_replaceChar(
789 sal_Unicode
* str
, sal_Unicode oldChar
, sal_Unicode newChar
) SAL_THROW_EXTERN_C();
791 /** Replace all occurrences of a single character within a string.
793 If oldChar does not occur within str, then the string is not modified.
796 a string. Need not be null-terminated, but must be at least as long as
800 the length of the string.
808 SAL_DLLPUBLIC
void SAL_CALL
rtl_ustr_replaceChar_WithLength(
809 sal_Unicode
* str
, sal_Int32 len
, sal_Unicode oldChar
, sal_Unicode newChar
) SAL_THROW_EXTERN_C();
811 /** Convert all ASCII uppercase letters to lowercase within a string.
813 The characters with values between 65 and 90 (ASCII A--Z) are replaced
814 with values between 97 and 122 (ASCII a--z). The string must be
818 a null-terminated string.
820 SAL_DLLPUBLIC
void SAL_CALL
rtl_ustr_toAsciiLowerCase(
821 sal_Unicode
* str
) SAL_THROW_EXTERN_C();
823 /** Convert all ASCII uppercase letters to lowercase within a string.
825 The characters with values between 65 and 90 (ASCII A--Z) are replaced
826 with values between 97 and 122 (ASCII a--z).
829 a string. Need not be null-terminated, but must be at least as long as
833 the length of the string.
835 SAL_DLLPUBLIC
void SAL_CALL
rtl_ustr_toAsciiLowerCase_WithLength(
836 sal_Unicode
* str
, sal_Int32 len
) SAL_THROW_EXTERN_C();
838 /** Convert all ASCII lowercase letters to uppercase within a string.
840 The characters with values between 97 and 122 (ASCII a--z) are replaced
841 with values between 65 and 90 (ASCII A--Z). The string must be
845 a null-terminated string.
847 SAL_DLLPUBLIC
void SAL_CALL
rtl_ustr_toAsciiUpperCase(
848 sal_Unicode
* str
) SAL_THROW_EXTERN_C();
850 /** Convert all ASCII lowercase letters to uppercase within a string.
852 The characters with values between 97 and 122 (ASCII a--z) are replaced
853 with values between 65 and 90 (ASCII A--Z).
856 a string. Need not be null-terminated, but must be at least as long as
860 the length of the string.
862 SAL_DLLPUBLIC
void SAL_CALL
rtl_ustr_toAsciiUpperCase_WithLength(
863 sal_Unicode
* str
, sal_Int32 len
) SAL_THROW_EXTERN_C();
865 /** Remove white space from both ends of a string.
867 All characters with values less than or equal to 32 (the space character)
868 are considered to be white space. This function cannot be used for
869 language-specific operations. The string must be null-terminated.
872 a null-terminated string.
875 the new length of the string.
877 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_trim(
878 sal_Unicode
* str
) SAL_THROW_EXTERN_C();
880 /** Remove white space from both ends of the string.
882 All characters with values less than or equal to 32 (the space character)
883 are considered to be white space. This function cannot be used for
884 language-specific operations. The string must be null-terminated.
887 a string. Need not be null-terminated, but must be at least as long as
891 the original length of the string.
894 the new length of the string.
896 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_trim_WithLength(
897 sal_Unicode
* str
, sal_Int32 len
) SAL_THROW_EXTERN_C();
899 /** Create the string representation of a boolean.
901 If b is true, the buffer is filled with the string "true" and 4 is
902 returned. If b is false, the buffer is filled with the string "false" and
903 5 is returned. This function cannot be used for language-specific
907 a buffer that is big enough to hold the result and the terminating NUL
908 character. You should use the RTL_USTR_MAX_VALUEOFBOOLEAN define to
909 create a buffer that is big enough.
915 the length of the string.
917 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_valueOfBoolean(
918 sal_Unicode
* str
, sal_Bool b
) SAL_THROW_EXTERN_C();
919 #define RTL_USTR_MAX_VALUEOFBOOLEAN RTL_STR_MAX_VALUEOFBOOLEAN
921 /** Create the string representation of a character.
924 a buffer that is big enough to hold the result and the terminating NUL
925 character. You should use the RTL_USTR_MAX_VALUEOFCHAR define to create a
926 buffer that is big enough.
932 the length of the string.
934 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_valueOfChar(
935 sal_Unicode
* str
, sal_Unicode ch
) SAL_THROW_EXTERN_C();
936 #define RTL_USTR_MAX_VALUEOFCHAR RTL_STR_MAX_VALUEOFCHAR
938 /** Create the string representation of an integer.
940 This function cannot be used for language-specific operations.
943 a buffer that is big enough to hold the result and the terminating NUL
944 character. You should use the RTL_USTR_MAX_VALUEOFINT32 define to create
945 a buffer that is big enough.
951 the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
955 the length of the string.
957 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_valueOfInt32(
958 sal_Unicode
* str
, sal_Int32 i
, sal_Int16 radix
) SAL_THROW_EXTERN_C();
959 #define RTL_USTR_MIN_RADIX RTL_STR_MIN_RADIX
960 #define RTL_USTR_MAX_RADIX RTL_STR_MAX_RADIX
961 #define RTL_USTR_MAX_VALUEOFINT32 RTL_STR_MAX_VALUEOFINT32
963 /** Create the string representation of a long integer.
965 This function cannot be used for language-specific operations.
968 a buffer that is big enough to hold the result and the terminating NUL
969 character. You should use the RTL_USTR_MAX_VALUEOFINT64 define to create
970 a buffer that is big enough.
973 a long integer value.
976 the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
980 the length of the string.
982 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_valueOfInt64(
983 sal_Unicode
* str
, sal_Int64 l
, sal_Int16 radix
) SAL_THROW_EXTERN_C();
984 #define RTL_USTR_MAX_VALUEOFINT64 RTL_STR_MAX_VALUEOFINT64
986 /** Create the string representation of an unsigned long integer.
988 This function cannot be used for language-specific operations.
991 a buffer that is big enough to hold the result and the terminating NUL
992 character. You should use the RTL_USTR_MAX_VALUEOFUINT64 define to create
993 a buffer that is big enough.
996 a long integer value.
999 the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
1003 the length of the string.
1005 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_valueOfUInt64(
1006 sal_Unicode
* str
, sal_uInt64 l
, sal_Int16 radix
) SAL_THROW_EXTERN_C();
1007 #define RTL_USTR_MAX_VALUEOFUINT64 RTL_STR_MAX_VALUEOFUINT64
1009 /** Create the string representation of a float.
1011 This function cannot be used for language-specific conversion.
1014 a buffer that is big enough to hold the result and the terminating NUL
1015 character. You should use the RTL_USTR_MAX_VALUEOFFLOAT define to create
1016 a buffer that is big enough.
1022 the length of the string.
1024 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_valueOfFloat(
1025 sal_Unicode
* str
, float f
) SAL_THROW_EXTERN_C();
1026 #define RTL_USTR_MAX_VALUEOFFLOAT RTL_STR_MAX_VALUEOFFLOAT
1028 /** Create the string representation of a double.
1030 This function cannot be used for language-specific conversion.
1033 a buffer that is big enough to hold the result and the terminating NUL
1034 character. You should use the RTL_USTR_MAX_VALUEOFDOUBLE define to create
1035 a buffer that is big enough.
1041 the length of the string.
1043 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_valueOfDouble(
1044 sal_Unicode
* str
, double d
) SAL_THROW_EXTERN_C();
1045 #define RTL_USTR_MAX_VALUEOFDOUBLE RTL_STR_MAX_VALUEOFDOUBLE
1047 /** Interpret a string as a boolean.
1049 This function cannot be used for language-specific conversion. The string
1050 must be null-terminated.
1053 a null-terminated string.
1056 true if the string is "1" or "true" in any ASCII case, false otherwise.
1058 SAL_DLLPUBLIC sal_Bool SAL_CALL
rtl_ustr_toBoolean(
1059 const sal_Unicode
* str
) SAL_THROW_EXTERN_C();
1061 /** Interpret a string as an integer.
1063 This function cannot be used for language-specific conversion. The string
1064 must be null-terminated.
1067 a null-terminated string.
1070 the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
1074 the integer value represented by the string, or 0 if the string does not
1075 represent an integer.
1077 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_ustr_toInt32(
1078 const sal_Unicode
* str
, sal_Int16 radix
) SAL_THROW_EXTERN_C();
1080 /** Interpret a string as an unsigned integer.
1082 This function cannot be used for language-specific conversion. The string
1083 must be null-terminated.
1086 a null-terminated string.
1089 the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
1093 the unsigned integer value represented by the string, or 0 if the string
1094 does not represent an unsigned integer.
1096 @since LibreOffice 4.2
1098 SAL_DLLPUBLIC sal_uInt32 SAL_CALL
rtl_ustr_toUInt32(
1099 const sal_Unicode
* str
, sal_Int16 radix
) SAL_THROW_EXTERN_C();
1101 /** Interpret a string as a long integer.
1103 This function cannot be used for language-specific conversion. The string
1104 must be null-terminated.
1107 a null-terminated string.
1110 the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
1114 the long integer value represented by the string, or 0 if the string does
1115 not represent a long integer.
1117 SAL_DLLPUBLIC sal_Int64 SAL_CALL
rtl_ustr_toInt64(
1118 const sal_Unicode
* str
, sal_Int16 radix
) SAL_THROW_EXTERN_C();
1120 /** Interpret a string as a long integer.
1122 This function cannot be used for language-specific conversion.
1128 the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
1132 number of chars to process
1135 the long integer value represented by the string, or 0 if the string does
1136 not represent a long integer.
1139 @since LibreOffice 6.4
1141 SAL_DLLPUBLIC sal_Int64 SAL_CALL
rtl_ustr_toInt64_WithLength(
1142 const sal_Unicode
* str
, sal_Int16 radix
, sal_Int32 nStrLength
) SAL_THROW_EXTERN_C();
1144 /** Interpret a string as an unsigned long integer.
1146 This function cannot be used for language-specific conversion. The string
1147 must be null-terminated.
1150 a null-terminated string.
1153 the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
1157 the unsigned long integer value represented by the string, or 0 if the
1158 string does not represent an unsigned long integer.
1160 @since LibreOffice 4.1
1162 SAL_DLLPUBLIC sal_uInt64 SAL_CALL
rtl_ustr_toUInt64(
1163 const sal_Unicode
* str
, sal_Int16 radix
) SAL_THROW_EXTERN_C();
1165 /** Interpret a string as a float.
1167 This function cannot be used for language-specific conversion. The string
1168 must be null-terminated.
1171 a null-terminated string.
1174 the float value represented by the string, or 0.0 if the string does not
1177 SAL_DLLPUBLIC
float SAL_CALL
rtl_ustr_toFloat(
1178 const sal_Unicode
* str
) SAL_THROW_EXTERN_C();
1180 /** Interpret a string as a double.
1182 This function cannot be used for language-specific conversion. The string
1183 must be null-terminated.
1186 a null-terminated string.
1189 the float value represented by the string, or 0.0 if the string does not
1192 SAL_DLLPUBLIC
double SAL_CALL
rtl_ustr_toDouble(
1193 const sal_Unicode
* str
) SAL_THROW_EXTERN_C();
1195 /* ======================================================================= */
1197 /** @cond INTERNAL */
1198 /** The implementation of a Unicode string.
1200 struct SAL_DLLPUBLIC_RTTI _rtl_uString
;
1201 typedef struct _rtl_uString
1203 oslInterlockedCount refCount
; /* opaque */
1205 sal_Unicode buffer
[1];
1209 /* ----------------------------------------------------------------------- */
1211 /** Increment the reference count of a string.
1216 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_acquire(
1217 rtl_uString
* str
) SAL_THROW_EXTERN_C() SAL_HOT
;
1219 /** Decrement the reference count of a string.
1221 If the count goes to zero than the string data is deleted.
1226 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_release(
1227 rtl_uString
* str
) SAL_THROW_EXTERN_C() SAL_HOT
;
1229 /** Allocate a new string containing no characters.
1232 pointer to the new string. The pointed-to data must be null or a valid
1235 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_new(
1236 rtl_uString
** newStr
) SAL_THROW_EXTERN_C();
1238 /** Allocate a new string containing space for a given number of characters.
1240 The reference count of the new string will be 1. The length of the string
1241 will be nLen. This function does not handle out-of-memory conditions.
1243 For failed allocation this method returns NULL.
1245 The characters of the capacity are not cleared, and the length is set to
1246 nLen, unlike the similar method of rtl_uString_new_WithLength which
1247 zeros out the buffer, and sets the length to 0. So should be somewhat
1248 more efficient for allocating a new string.
1250 call rtl_uString_release to release the string
1251 alternatively pass ownership to an OUString with
1252 rtl::OUString(newStr, SAL_NO_ACQUIRE);
1254 @param[in] nLen the number of characters. Must be >= 0.
1256 @return pointer to the new string.
1258 @since LibreOffice 4.1
1260 SAL_DLLPUBLIC rtl_uString
* SAL_CALL
rtl_uString_alloc(sal_Int32 nLen
) SAL_THROW_EXTERN_C();
1262 /** Allocate a new string containing space for a given number of characters.
1264 If len is greater than zero, the reference count of the new string will be
1265 1. The values of all characters are set to 0 and the length of the string
1266 is 0. This function does not handle out-of-memory conditions.
1269 pointer to the new string. The pointed-to data must be null or a valid
1273 the number of characters.
1275 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_new_WithLength(
1276 rtl_uString
** newStr
, sal_Int32 nLen
) SAL_THROW_EXTERN_C();
1278 /** Allocate a new string that contains a copy of another string.
1280 If the length of value is greater than zero, the reference count of the
1281 new string will be 1. This function does not handle out-of-memory
1285 pointer to the new string. The pointed-to data must be null or a valid
1291 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newFromString(
1292 rtl_uString
** newStr
, const rtl_uString
* value
) SAL_THROW_EXTERN_C();
1294 /** Allocate a new string that contains a copy of a character array.
1296 If the length of value is greater than zero, the reference count of the
1297 new string will be 1. This function does not handle out-of-memory
1301 pointer to the new string. The pointed-to data must be null or a valid
1305 a null-terminated character array.
1307 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newFromStr(
1308 rtl_uString
** newStr
, const sal_Unicode
* value
) SAL_THROW_EXTERN_C();
1310 /** Allocate a new string that contains a copy of a character array.
1312 If the length of value is greater than zero, the reference count of the
1313 new string will be 1. This function does not handle out-of-memory
1317 pointer to the new string. The pointed-to data must be null or a valid
1321 a character array. Need not be null-terminated, but must be at least as
1322 long as the specified len.
1325 the length of the character array.
1327 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newFromStr_WithLength(
1328 rtl_uString
** newStr
, const sal_Unicode
* value
, sal_Int32 len
) SAL_THROW_EXTERN_C();
1330 /** Allocate a new string that is a substring of this string.
1332 The substring begins at the specified beginIndex and contains count
1333 characters. Meaningless combinations such as negative beginIndex,
1334 or beginIndex + count greater than the length of the string have
1335 undefined behaviour.
1337 @param[out] newStr the specified substring.
1338 @param[in] from the String to take the substring from.
1339 @param[in] beginIndex the beginning index, inclusive.
1340 @param[in] count the number of characters.
1342 @since LibreOffice 4.0
1344 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newFromSubString(
1345 rtl_uString
** newStr
, const rtl_uString
* from
,
1346 sal_Int32 beginIndex
, sal_Int32 count
) SAL_THROW_EXTERN_C();
1348 /** Allocate a new string that contains a copy of a character array.
1350 If the length of value is greater than zero, the reference count of the
1351 new string will be 1. This function does not handle out-of-memory
1354 Since this function is optimized for performance, the ASCII character
1355 values are not converted in any way. The caller has to make sure that
1356 all ASCII characters are in the allowed range of 0 and 127, inclusive.
1359 pointer to the new string. The pointed-to data must be null or a valid
1363 a null-terminated ASCII character array.
1365 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newFromAscii(
1366 rtl_uString
** newStr
, const char * value
) SAL_THROW_EXTERN_C();
1370 @since LibreOffice 3.6
1372 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newFromLiteral(
1373 rtl_uString
** newStr
, const char * value
, sal_Int32 len
,
1374 sal_Int32 allocExtra
) SAL_THROW_EXTERN_C();
1376 /** Allocate a new string from an array of Unicode code points.
1379 a non-null pointer to a (possibly null) rtl_uString pointer, which (if
1380 non-null) will have been passed to rtl_uString_release before the function
1381 returns. Upon return, points to the newly allocated string or to null if
1382 there was either an out-of-memory condition or the resulting number of
1383 UTF-16 code units would have been larger than SAL_MAX_INT32. The newly
1384 allocated string (if any) must ultimately be passed to rtl_uString_release.
1387 an array of at least codePointCount code points, which each must be in the
1388 range from 0 to 0x10FFFF, inclusive. May be null if codePointCount is zero.
1390 @param codePointCount
1391 the non-negative number of code points.
1395 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newFromCodePoints(
1396 rtl_uString
** newString
, sal_uInt32
const * codePoints
,
1397 sal_Int32 codePointCount
) SAL_THROW_EXTERN_C();
1399 /** Assign a new value to a string.
1401 First releases any value str might currently hold, then acquires
1405 pointer to the string. The pointed-to data must be null or a valid
1411 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_assign(
1412 rtl_uString
** str
, rtl_uString
* rightValue
) SAL_THROW_EXTERN_C();
1414 /** Return the length of a string.
1416 The length is equal to the number of characters in the string.
1422 the length of the string.
1424 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_uString_getLength(
1425 const rtl_uString
* str
) SAL_THROW_EXTERN_C();
1427 /** Return a pointer to the underlying character array of a string.
1433 a pointer to the null-terminated character array.
1435 SAL_DLLPUBLIC sal_Unicode
* SAL_CALL
rtl_uString_getStr(
1436 rtl_uString
* str
) SAL_THROW_EXTERN_C();
1438 /** Create a new string that is the concatenation of two other strings.
1440 The new string does not necessarily have a reference count of 1 (in cases
1441 where one of the two other strings is empty), so it must not be modified
1442 without checking the reference count. This function does not handle
1443 out-of-memory conditions.
1446 pointer to the new string. The pointed-to data must be null or a valid
1455 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newConcat(
1456 rtl_uString
** newStr
, rtl_uString
* left
, rtl_uString
* right
) SAL_THROW_EXTERN_C();
1458 /** Create a new string that is the concatenation of two other strings.
1460 The new string does not necessarily have a reference count of 1 (in cases
1461 where the ASCII string is empty), so it must not be modified without
1462 checking the reference count.
1465 pointer to the new string. The pointed-to data must be null or a valid
1471 @param right must not be null and must point to memory of at least
1472 \p rightLength ASCII bytes
1474 @param rightLength the length of the \p right string; must be non-negative
1476 @since LibreOffice 5.1
1478 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newConcatAsciiL(
1479 rtl_uString
** newString
, rtl_uString
* left
, char const * right
,
1480 sal_Int32 rightLength
);
1482 /** Create a new string that is the concatenation of two other strings.
1484 The new string does not necessarily have a reference count of 1 (in cases
1485 where the UTF-16 string is empty), so it must not be modified without
1486 checking the reference count.
1488 @param newString pointer to the new string. The pointed-to data must be null
1491 @param left a valid string.
1493 @param right must point to memory of at least \p rightLength UTF-16 code units; may be null if
1494 \p rigthLength is zero
1496 @param rightLength the length of the \p right string; must be non-negative
1498 @since LibreOffice 5.3
1500 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newConcatUtf16L(
1501 rtl_uString
** newString
, rtl_uString
* left
, sal_Unicode
const * right
,
1502 sal_Int32 rightLength
);
1504 /** Create a new string by replacing a substring of another string.
1506 The new string results from replacing a number of characters (count),
1507 starting at the specified position (index) in the original string (str),
1508 with some new substring (subStr). If subStr is null, then only a number
1509 of characters is deleted.
1511 The new string does not necessarily have a reference count of 1, so it
1512 must not be modified without checking the reference count. This function
1513 does not handle out-of-memory conditions.
1516 pointer to the new string. The pointed-to data must be null or a valid
1523 the index into str at which to start replacement. Must be between 0 and
1524 the length of str, inclusive.
1527 the number of characters to remove. Must not be negative, and the sum of
1528 index and count must not exceed the length of str.
1531 either null or a valid string to be inserted.
1533 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplaceStrAt(
1534 rtl_uString
** newStr
, rtl_uString
* str
, sal_Int32 idx
, sal_Int32 count
, rtl_uString
* subStr
) SAL_THROW_EXTERN_C();
1536 #ifdef LIBO_INTERNAL_ONLY
1537 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplaceStrAtUtf16L(
1538 rtl_uString
** newStr
, rtl_uString
* str
, sal_Int32 idx
, sal_Int32 count
, sal_Unicode
const * subStr
, sal_Int32 substrLen
) SAL_THROW_EXTERN_C();
1541 /** Create a new string by replacing all occurrences of a single character
1542 within another string.
1544 The new string results from replacing all occurrences of oldChar in str
1547 The new string does not necessarily have a reference count of 1 (in cases
1548 where oldChar does not occur in str), so it must not be modified without
1549 checking the reference count. This function does not handle out-of-memory
1553 pointer to the new string. The pointed-to data must be null or a valid
1565 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplace(
1566 rtl_uString
** newStr
, rtl_uString
* str
, sal_Unicode oldChar
, sal_Unicode newChar
) SAL_THROW_EXTERN_C();
1568 /** Create a new string by replacing the first occurrence of a given substring
1569 with another substring.
1571 @param[in, out] newStr pointer to the new string; must not be null; must
1572 point to null or a valid rtl_uString
1574 @param str pointer to the original string; must not be null
1576 @param from pointer to the substring to be replaced; must not be null
1578 @param to pointer to the replacing substring; must not be null
1580 @param[in,out] index pointer to a start index, must not be null; upon entry
1581 to the function its value is the index into the original string at which to
1582 start searching for the \p from substring, the value must be non-negative
1583 and not greater than the original string's length; upon exit from the
1584 function its value is the index into the original string at which the
1585 replacement took place or -1 if no replacement took place
1587 @since LibreOffice 3.6
1589 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplaceFirst(
1590 rtl_uString
** newStr
, rtl_uString
* str
, rtl_uString
const * from
,
1591 rtl_uString
const * to
, sal_Int32
* index
) SAL_THROW_EXTERN_C();
1593 /** Create a new string by replacing the first occurrence of a given substring
1594 with another substring.
1596 @param[in, out] newStr pointer to the new string; must not be null; must
1597 point to null or a valid rtl_uString
1599 @param str pointer to the original string; must not be null
1601 @param from pointer to the substring to be replaced; must not be null and
1602 must point to memory of at least \p fromLength ASCII bytes
1604 @param fromLength the length of the \p from substring; must be non-negative
1606 @param to pointer to the replacing substring; must not be null
1608 @param[in,out] index pointer to a start index, must not be null; upon entry
1609 to the function its value is the index into the original string at which to
1610 start searching for the \p from substring, the value must be non-negative
1611 and not greater than the original string's length; upon exit from the
1612 function its value is the index into the original string at which the
1613 replacement took place or -1 if no replacement took place
1615 @since LibreOffice 3.6
1617 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplaceFirstAsciiL(
1618 rtl_uString
** newStr
, rtl_uString
* str
, char const * from
,
1619 sal_Int32 fromLength
, rtl_uString
const * to
, sal_Int32
* index
)
1620 SAL_THROW_EXTERN_C();
1622 /** Create a new string by replacing the first occurrence of a given substring
1623 with another substring.
1625 @param[in, out] newStr pointer to the new string; must not be null; must
1626 point to null or a valid rtl_uString
1628 @param str pointer to the original string; must not be null
1630 @param from pointer to the substring to be replaced; must not be null
1632 @param to pointer to the replacing substring; must not be null and must
1633 point to memory of at least \p toLength ASCII bytes
1635 @param toLength the length of the \p to substring; must be non-negative
1637 @param[in,out] index pointer to a start index, must not be null; upon entry
1638 to the function its value is the index into the original string at which to
1639 start searching for the \p from substring, the value must be non-negative
1640 and not greater than the original string's length; upon exit from the
1641 function its value is the index into the original string at which the
1642 replacement took place or -1 if no replacement took place
1644 @since LibreOffice 5.1
1646 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplaceFirstToAsciiL(
1647 rtl_uString
** newStr
, rtl_uString
* str
, rtl_uString
const * from
,
1648 char const * to
, sal_Int32 toLength
, sal_Int32
* index
)
1649 SAL_THROW_EXTERN_C();
1651 /** Create a new string by replacing the first occurrence of a given substring
1652 with another substring.
1654 @param[in, out] newStr pointer to the new string; must not be null; must
1655 point to null or a valid rtl_uString
1657 @param str pointer to the original string; must not be null
1659 @param from pointer to the substring to be replaced; must not be null and
1660 must point to memory of at least \p fromLength ASCII bytes
1662 @param fromLength the length of the \p from substring; must be non-negative
1664 @param to pointer to the substring to be replaced; must not be null and
1665 must point to memory of at least \p toLength ASCII bytes
1667 @param toLength the length of the \p to substring; must be non-negative
1669 @param[in,out] index pointer to a start index, must not be null; upon entry
1670 to the function its value is the index into the original string at which to
1671 start searching for the \p from substring, the value must be non-negative
1672 and not greater than the original string's length; upon exit from the
1673 function its value is the index into the original string at which the
1674 replacement took place or -1 if no replacement took place
1676 @since LibreOffice 3.6
1678 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplaceFirstAsciiLAsciiL(
1679 rtl_uString
** newStr
, rtl_uString
* str
, char const * from
,
1680 sal_Int32 fromLength
, char const * to
, sal_Int32 toLength
,
1681 sal_Int32
* index
) SAL_THROW_EXTERN_C();
1683 /** Create a new string by replacing the first occurrence of a given substring
1684 with another substring.
1686 @param[in, out] newStr pointer to the new string; must not be null; must
1687 point to null or a valid rtl_uString; upon return, points to the newly
1688 allocated string or to null if there was either an out-of-memory condition
1689 or the resulting number of UTF-16 code units would have been larger than
1692 @param str pointer to the original string; must not be null
1694 @param from pointer to the substring to be replaced; must not be null and
1695 must point to memory of at least \p fromLength ASCII bytes
1697 @param fromLength the length of the \p from substring; must be non-negative
1699 @param to pointer to the substring to be replaced; must not be null and
1700 must point to memory of at least \p toLength UTF-16 code units
1702 @param toLength the length of the \p to substring; must be non-negative
1704 @param[in,out] index pointer to a start index, must not be null; upon entry
1705 to the function its value is the index into the original string at which to
1706 start searching for the \p from substring, the value must be non-negative
1707 and not greater than the original string's length; upon exit from the
1708 function its value is the index into the original string at which the
1709 replacement took place (or would have taken place if \p newStr points to
1710 null upon return) or -1 if no replacement took place
1712 @since LibreOffice 5.3
1714 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplaceFirstAsciiLUtf16L(
1715 rtl_uString
** newStr
, rtl_uString
* str
, char const * from
,
1716 sal_Int32 fromLength
, sal_Unicode
const * to
, sal_Int32 toLength
,
1717 sal_Int32
* index
) SAL_THROW_EXTERN_C();
1719 /** Create a new string by replacing the first occurrence of a given substring
1720 with another substring.
1722 @param[in, out] newStr pointer to the new string; must not be null; must
1723 point to null or a valid rtl_uString; upon return, points to the newly
1724 allocated string or to null if there was either an out-of-memory condition
1725 or the resulting number of UTF-16 code units would have been larger than
1728 @param str pointer to the original string; must not be null
1730 @param from pointer to the substring to be replaced; must not be null and
1731 must point to memory of at least \p fromLength UTF-16 code units
1733 @param fromLength the length of the \p from substring; must be non-negative
1735 @param to pointer to the substring to be replaced; must not be null and
1736 must point to memory of at least \p toLength ASCII bytes
1738 @param toLength the length of the \p to substring; must be non-negative
1740 @param[in,out] index pointer to a start index, must not be null; upon entry
1741 to the function its value is the index into the original string at which to
1742 start searching for the \p from substring, the value must be non-negative
1743 and not greater than the original string's length; upon exit from the
1744 function its value is the index into the original string at which the
1745 replacement took place (or would have taken place if \p newStr points to
1746 null upon return) or -1 if no replacement took place
1748 @since LibreOffice 5.3
1750 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplaceFirstUtf16LAsciiL(
1751 rtl_uString
** newStr
, rtl_uString
* str
, sal_Unicode
const * from
,
1752 sal_Int32 fromLength
, char const * to
, sal_Int32 toLength
,
1753 sal_Int32
* index
) SAL_THROW_EXTERN_C();
1755 /** Create a new string by replacing the first occurrence of a given substring
1756 with another substring.
1758 @param[in, out] newStr pointer to the new string; must not be null; must
1759 point to null or a valid rtl_uString; upon return, points to the newly
1760 allocated string or to null if there was either an out-of-memory condition
1761 or the resulting number of UTF-16 code units would have been larger than
1764 @param str pointer to the original string; must not be null
1766 @param from pointer to the substring to be replaced; must point to memory of at least
1767 \p fromLength UTF-16 code units; may be null if \p toLength is zero
1769 @param fromLength the length of the \p from substring; must be non-negative
1771 @param to pointer to the substring to be replaced; must point to memory of at least \p toLength
1772 UTF-16 code units; may be null if \p toLength is zero
1774 @param toLength the length of the \p to substring; must be non-negative
1776 @param[in,out] index pointer to a start index, must not be null; upon entry
1777 to the function its value is the index into the original string at which to
1778 start searching for the \p from substring, the value must be non-negative
1779 and not greater than the original string's length; upon exit from the
1780 function its value is the index into the original string at which the
1781 replacement took place (or would have taken place if \p newStr points to
1782 null upon return) or -1 if no replacement took place
1784 @since LibreOffice 5.3
1786 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplaceFirstUtf16LUtf16L(
1787 rtl_uString
** newStr
, rtl_uString
* str
, sal_Unicode
const * from
,
1788 sal_Int32 fromLength
, sal_Unicode
const * to
, sal_Int32 toLength
,
1789 sal_Int32
* index
) SAL_THROW_EXTERN_C();
1791 /** Create a new string by replacing all occurrences of a given substring with
1794 Replacing subsequent occurrences picks up only after a given replacement.
1795 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
1797 @param[in, out] newStr pointer to the new string; must not be null; must
1798 point to null or a valid rtl_uString
1800 @param str pointer to the original string; must not be null
1802 @param from pointer to the substring to be replaced; must not be null
1804 @param to pointer to the replacing substring; must not be null
1806 @since LibreOffice 3.6
1808 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplaceAll(
1809 rtl_uString
** newStr
, rtl_uString
* str
, rtl_uString
const * from
,
1810 rtl_uString
const * to
) SAL_THROW_EXTERN_C();
1812 /** Create a new string by replacing all occurrences of a given substring with
1815 Replacing subsequent occurrences picks up only after a given replacement.
1816 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
1818 @param[in, out] newStr pointer to the new string; must not be null; must
1819 point to null or a valid rtl_uString
1821 @param str pointer to the original string; must not be null
1823 @param from pointer to the substring to be replaced; must not be null
1825 @param to pointer to the replacing substring; must not be null
1827 @param fromIndex the position in the string where we will begin searching
1829 @since LibreOffice 4.0
1831 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplaceAllFromIndex(
1832 rtl_uString
** newStr
, rtl_uString
* str
, rtl_uString
const * from
,
1833 rtl_uString
const * to
, sal_Int32 fromIndex
) SAL_THROW_EXTERN_C();
1835 /** Create a new string by replacing all occurrences of a given substring with
1838 Replacing subsequent occurrences picks up only after a given replacement.
1839 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
1841 @param[in, out] newStr pointer to the new string; must not be null; must
1842 point to null or a valid rtl_uString
1844 @param str pointer to the original string; must not be null
1846 @param from pointer to the substring to be replaced; must not be null and
1847 must point to memory of at least \p fromLength ASCII bytes
1849 @param fromLength the length of the \p from substring; must be non-negative
1851 @param to pointer to the replacing substring; must not be null
1853 @since LibreOffice 3.6
1855 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplaceAllAsciiL(
1856 rtl_uString
** newStr
, rtl_uString
* str
, char const * from
,
1857 sal_Int32 fromLength
, rtl_uString
const * to
) SAL_THROW_EXTERN_C();
1859 /** Create a new string by replacing all occurrences of a given substring with
1862 Replacing subsequent occurrences picks up only after a given replacement.
1863 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
1865 @param[in, out] newStr pointer to the new string; must not be null; must
1866 point to null or a valid rtl_uString
1868 @param str pointer to the original string; must not be null
1870 @param from pointer to the substring to be replaced; must not be null
1872 @param to pointer to the replacing substring; must not be null and must
1873 point to memory of at least \p toLength ASCII bytes
1875 @param toLength the length of the \p to substring; must be non-negative
1877 @since LibreOffice 5.1
1879 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplaceAllToAsciiL(
1880 rtl_uString
** newStr
, rtl_uString
* str
, rtl_uString
const * from
,
1881 char const * to
, sal_Int32 toLength
) SAL_THROW_EXTERN_C();
1883 /** Create a new string by replacing all occurrences of a given substring with
1886 Replacing subsequent occurrences picks up only after a given replacement.
1887 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
1889 @param[in, out] newStr pointer to the new string; must not be null; must
1890 point to null or a valid rtl_uString
1892 @param str pointer to the original string; must not be null
1894 @param from pointer to the substring to be replaced; must not be null and
1895 must point to memory of at least \p fromLength ASCII bytes
1897 @param fromLength the length of the \p from substring; must be non-negative
1899 @param to pointer to the substring to be replaced; must not be null and
1900 must point to memory of at least \p toLength ASCII bytes
1902 @param toLength the length of the \p to substring; must be non-negative
1904 @since LibreOffice 3.6
1906 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplaceAllAsciiLAsciiL(
1907 rtl_uString
** newStr
, rtl_uString
* str
, char const * from
,
1908 sal_Int32 fromLength
, char const * to
, sal_Int32 toLength
)
1909 SAL_THROW_EXTERN_C();
1911 /** Create a new string by replacing all occurrences of a given substring with
1914 Replacing subsequent occurrences picks up only after a given replacement.
1915 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
1917 @param[in, out] newStr pointer to the new string; must not be null; must
1918 point to null or a valid rtl_uString; upon return, points to the newly
1919 allocated string or to null if there was either an out-of-memory condition
1920 or the resulting number of UTF-16 code units would have been larger than
1923 @param str pointer to the original string; must not be null
1925 @param from pointer to the substring to be replaced; must not be null and
1926 must point to memory of at least \p fromLength ASCII bytes
1928 @param fromLength the length of the \p from substring; must be non-negative
1930 @param to pointer to the substring to be replaced; must point to memory of at least \p toLength
1931 UTF-16 code units; may be null if \p toLength is zero
1933 @param toLength the length of the \p to substring; must be non-negative
1935 @since LibreOffice 3.6
1937 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplaceAllAsciiLUtf16L(
1938 rtl_uString
** newStr
, rtl_uString
* str
, char const * from
,
1939 sal_Int32 fromLength
, sal_Unicode
const * to
, sal_Int32 toLength
)
1940 SAL_THROW_EXTERN_C();
1942 /** Create a new string by replacing all occurrences of a given substring with
1945 Replacing subsequent occurrences picks up only after a given replacement.
1946 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
1948 @param[in, out] newStr pointer to the new string; must not be null; must
1949 point to null or a valid rtl_uString; upon return, points to the newly
1950 allocated string or to null if there was either an out-of-memory condition
1951 or the resulting number of UTF-16 code units would have been larger than
1954 @param str pointer to the original string; must not be null
1956 @param from pointer to the substring to be replaced; must not be null and
1957 must point to memory of at least \p fromLength UTF-16 code units
1959 @param fromLength the length of the \p from substring; must be non-negative
1961 @param to pointer to the substring to be replaced; must not be null and
1962 must point to memory of at least \p toLength ASCII bytes
1964 @param toLength the length of the \p to substring; must be non-negative
1966 @since LibreOffice 3.6
1968 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplaceAllUtf16LAsciiL(
1969 rtl_uString
** newStr
, rtl_uString
* str
, sal_Unicode
const * from
,
1970 sal_Int32 fromLength
, char const * to
, sal_Int32 toLength
)
1971 SAL_THROW_EXTERN_C();
1973 /** Create a new string by replacing all occurrences of a given substring with
1976 Replacing subsequent occurrences picks up only after a given replacement.
1977 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
1979 @param[in, out] newStr pointer to the new string; must not be null; must
1980 point to null or a valid rtl_uString; upon return, points to the newly
1981 allocated string or to null if there was either an out-of-memory condition
1982 or the resulting number of UTF-16 code units would have been larger than
1985 @param str pointer to the original string; must not be null
1987 @param from pointer to the substring to be replaced; must not be null and
1988 must point to memory of at least \p fromLength UTF-16 code units
1990 @param fromLength the length of the \p from substring; must be non-negative
1992 @param to pointer to the substring to be replaced; must not be null and
1993 must point to memory of at least \p toLength UTF-16 code units
1995 @param toLength the length of the \p to substring; must be non-negative
1997 @since LibreOffice 3.6
1999 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplaceAllUtf16LUtf16L(
2000 rtl_uString
** newStr
, rtl_uString
* str
, sal_Unicode
const * from
,
2001 sal_Int32 fromLength
, sal_Unicode
const * to
, sal_Int32 toLength
)
2002 SAL_THROW_EXTERN_C();
2004 #if defined LIBO_INTERNAL_ONLY
2005 /** Create a new string by replacing all occurrences of a given substring with
2008 Replacing subsequent occurrences picks up only after a given replacement.
2009 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
2011 @param[in, out] newStr pointer to the new string; must not be null; must
2012 point to null or a valid rtl_uString; upon return, points to the newly
2013 allocated string or to null if there was either an out-of-memory condition
2014 or the resulting number of UTF-16 code units would have been larger than
2017 @param str pointer to the original string; must not be null
2019 @param from pointer to the substring to be replaced; must not be null and
2020 must point to memory of at least \p fromLength UTF-16 code units
2022 @param fromLength the length of the \p from substring; must be non-negative
2024 @param to pointer to the substring to be replaced; must not be null and
2025 must point to memory of at least \p toLength UTF-16 code units
2027 @param toLength the length of the \p to substring; must be non-negative
2029 @param fromIndex the position in the string where we will begin searching
2031 @since LibreOffice 7.1
2033 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newReplaceAllFromIndexUtf16LUtf16L(
2034 rtl_uString
** newStr
, rtl_uString
* str
, sal_Unicode
const * from
,
2035 sal_Int32 fromLength
, sal_Unicode
const * to
, sal_Int32 toLength
, sal_Int32 fromIndex
)
2036 SAL_THROW_EXTERN_C();
2039 /** Create a new string by converting all ASCII uppercase letters to lowercase
2040 within another string.
2042 The new string results from replacing all characters with values between
2043 65 and 90 (ASCII A--Z) by values between 97 and 122 (ASCII a--z).
2045 This function cannot be used for language-specific conversion. The new
2046 string does not necessarily have a reference count of 1 (in cases where
2047 no characters need to be converted), so it must not be modified without
2048 checking the reference count. This function does not handle out-of-memory
2052 pointer to the new string. The pointed-to data must be null or a valid
2058 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newToAsciiLowerCase(
2059 rtl_uString
** newStr
, rtl_uString
* str
) SAL_THROW_EXTERN_C();
2061 /** Create a new string by converting all ASCII lowercase letters to uppercase
2062 within another string.
2064 The new string results from replacing all characters with values between
2065 97 and 122 (ASCII a--z) by values between 65 and 90 (ASCII A--Z).
2067 This function cannot be used for language-specific conversion. The new
2068 string does not necessarily have a reference count of 1 (in cases where
2069 no characters need to be converted), so it must not be modified without
2070 checking the reference count. This function does not handle out-of-memory
2074 pointer to the new string. The pointed-to data must be null or a valid
2080 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newToAsciiUpperCase(
2081 rtl_uString
** newStr
, rtl_uString
* str
) SAL_THROW_EXTERN_C();
2083 /** Create a new string by removing white space from both ends of another
2086 The new string results from removing all characters with values less than
2087 or equal to 32 (the space character), and also Unicode General Punctuation
2088 area Space and some Control characters, form both ends of str (see
2091 This function cannot be used for language-specific conversion. The new
2092 string does not necessarily have a reference count of 1 (in cases where
2093 no characters need to be removed), so it must not be modified without
2094 checking the reference count. This function does not handle out-of-memory
2098 pointer to the new string. The pointed-to data must be null or a valid
2104 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_newTrim(
2105 rtl_uString
** newStr
, rtl_uString
* str
) SAL_THROW_EXTERN_C();
2107 /** Create a new string by extracting a single token from another string.
2109 Starting at index, the token's next token is searched for. If there is no
2110 such token, the result is an empty string. Otherwise, all characters from
2111 the start of that token and up to, but not including the next occurrence
2112 of cTok make up the resulting token. The return value is the position of
2113 the next token, or -1 if no more tokens follow.
2115 Example code could look like
2116 rtl_uString * pToken = NULL;
2117 sal_Int32 nIndex = 0;
2121 nIndex = rtl_uString_getToken(&pToken, pStr, 0, ';', nIndex);
2124 while (nIndex >= 0);
2126 The new string does not necessarily have a reference count of 1, so it
2127 must not be modified without checking the reference count. This function
2128 does not handle out-of-memory conditions.
2131 pointer to the new string. The pointed-to data must be null or a valid
2132 string. If either token or index is negative, an empty token is stored in
2133 newStr (and -1 is returned).
2139 the number of the token to return, starting at index.
2142 the character that separates the tokens.
2145 the position at which searching for the token starts. Must not be greater
2146 than the length of str.
2149 the index of the next token, or -1 if no more tokens follow.
2151 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_uString_getToken(
2152 rtl_uString
** newStr
, rtl_uString
* str
, sal_Int32 token
, sal_Unicode cTok
, sal_Int32 idx
) SAL_THROW_EXTERN_C();
2154 /* ======================================================================= */
2156 /** Supply an ASCII string literal together with its length and text encoding.
2158 This macro can be used to compute (some of) the arguments in function calls
2159 like rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo")).
2161 @param constAsciiStr
2162 must be an expression of type "(possibly cv-qualified reference to) array of
2163 (possibly cv-qualified) char." Each element of the referenced array must
2164 represent an ASCII value in the range 0x00--0x7F. The last element of the
2165 referenced array is not considered part of the represented ASCII string, and
2166 its value should be 0x00. Depending on where this macro is used, the nature
2167 of the supplied expression might be further restricted.
2169 // The &foo[0] trick is intentional, it makes sure the type is char* or const char*
2170 // (plain cast to const char* would not work with non-const char foo[]="a", which seems to be allowed).
2171 // This is to avoid mistaken use with functions that accept string literals
2172 // (i.e. const char (&)[N]) where usage of this macro otherwise could match
2173 // the argument and a following int argument with a default value (e.g. OUString::match()).
2174 #define RTL_CONSTASCII_USTRINGPARAM( constAsciiStr ) (&(constAsciiStr)[0]), \
2175 ((sal_Int32)(SAL_N_ELEMENTS(constAsciiStr)-1)), RTL_TEXTENCODING_ASCII_US
2177 /* ======================================================================= */
2179 /* predefined constants for String-Conversion */
2180 #define OSTRING_TO_OUSTRING_CVTFLAGS (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE |\
2181 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT |\
2182 RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT)
2184 /* ----------------------------------------------------------------------- */
2186 /** Create a new Unicode string by converting a byte string, using a specific
2189 The lengths of the byte string and the Unicode string may differ (e.g.,
2190 for double-byte encodings, UTF-7, UTF-8).
2192 If the length of the byte string is greater than zero, the reference count
2193 of the new string will be 1.
2195 If an out-of-memory condition occurs, newStr will point to a null pointer
2199 pointer to the new string. The pointed-to data must be null or a valid
2203 a byte character array. Need not be null-terminated, but must be at
2204 least as long as the specified len.
2207 the length of the byte character array.
2210 the text encoding to use for conversion.
2213 flags which control the conversion. Either use
2214 OSTRING_TO_OUSTRING_CVTFLAGS, or see
2215 <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
2218 SAL_DLLPUBLIC
void SAL_CALL
rtl_string2UString(
2219 rtl_uString
** newStr
, const char * str
, sal_Int32 len
, rtl_TextEncoding encoding
, sal_uInt32 convertFlags
) SAL_THROW_EXTERN_C();
2221 /* ======================================================================= */
2222 /* Interning methods */
2224 /** Return a canonical representation for a string.
2226 A pool of strings, initially empty is maintained privately
2227 by the string class. On invocation, if present in the pool
2228 the original string will be returned. Otherwise this string,
2229 or a copy thereof will be added to the pool and returned.
2232 pointer to the new string. The pointed-to data must be null or a valid
2235 If an out-of-memory condition occurs, newStr will point to a null pointer
2239 pointer to the string to be interned.
2243 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_intern(
2244 rtl_uString
** newStr
, rtl_uString
* str
) SAL_THROW_EXTERN_C();
2246 /** Return a canonical representation for a string.
2248 A pool of strings, initially empty is maintained privately
2249 by the string class. On invocation, if present in the pool
2250 the original string will be returned. Otherwise this string,
2251 or a copy thereof will be added to the pool and returned.
2254 pointer to the new string. The pointed-to data must be null or a valid
2257 If an out-of-memory condition occurs, newStr will point to a null pointer
2261 a byte character array. Need not be null-terminated, but must be at
2262 least as long as the specified len.
2265 the length of the byte character array.
2268 the text encoding to use for conversion.
2271 flags which control the conversion. Either use
2272 OSTRING_TO_OUSTRING_CVTFLAGS, or see
2273 <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
2277 pointer to return conversion status in, or NULL.
2281 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_internConvert(
2282 rtl_uString
** newStr
,
2285 rtl_TextEncoding encoding
,
2286 sal_uInt32 convertFlags
,
2287 sal_uInt32
*pInfo
) SAL_THROW_EXTERN_C();
2289 /** Iterate through a string based on code points instead of UTF-16 code units.
2291 See Chapter 3 of The Unicode Standard 5.0 (Addison--Wesley, 2006) for
2292 definitions of the various terms used in this description.
2294 The given string is interpreted as a sequence of zero or more UTF-16 code
2295 units. For each index into this sequence (from zero to one less than the
2296 length of the sequence, inclusive), a code point represented starting at the
2297 given index is computed as follows:
2299 - If the UTF-16 code unit addressed by the index constitutes a well-formed
2300 UTF-16 code unit sequence, the computed code point is the scalar value
2301 encoded by that UTF-16 code unit sequence.
2303 - Otherwise, if the index is at least two UTF-16 code units away from the
2304 end of the sequence, and the sequence of two UTF-16 code units addressed by
2305 the index constitutes a well-formed UTF-16 code unit sequence, the computed
2306 code point is the scalar value encoded by that UTF-16 code unit sequence.
2308 - Otherwise, the computed code point is the UTF-16 code unit addressed by
2309 the index. (This last case catches unmatched surrogates as well as indices
2310 pointing into the middle of surrogate pairs.)
2313 pointer to a valid string; must not be null.
2316 pointer to a UTF-16 based index into the given string; must not be null. On
2317 entry, the index must be in the range from zero to the length of the string
2318 (in UTF-16 code units), inclusive. Upon successful return, the index will
2319 be updated to address the UTF-16 code unit that is the given
2320 incrementCodePoints away from the initial index.
2322 @param incrementCodePoints
2323 the number of code points to move the given *indexUtf16. If non-negative,
2324 moving is done after determining the code point at the index. If negative,
2325 moving is done before determining the code point at the (then updated)
2326 index. The value must be such that the resulting UTF-16 based index is in
2327 the range from zero to the length of the string (in UTF-16 code units),
2331 the code point (an integer in the range from 0 to 0x10FFFF, inclusive) that
2332 is represented within the string starting at the index computed as follows:
2333 If incrementCodePoints is non-negative, the index is the initial value of
2334 *indexUtf16; if incrementCodePoints is negative, the index is the updated
2335 value of *indexUtf16. In either case, the computed index must be in the
2336 range from zero to one less than the length of the string (in UTF-16 code
2341 SAL_DLLPUBLIC sal_uInt32 SAL_CALL
rtl_uString_iterateCodePoints(
2342 rtl_uString
const * string
, sal_Int32
* indexUtf16
,
2343 sal_Int32 incrementCodePoints
);
2345 /** Converts a byte string to a Unicode string, signalling failure.
2348 An out parameter receiving the converted string. Must not be null itself,
2349 and must contain either null or a pointer to a valid rtl_uString; the
2350 contents are unspecified if conversion fails (rtl_convertStringToUString
2354 The byte string. May only be null if length is zero.
2357 The length of the byte string. Must be non-negative.
2360 The text encoding to convert from. Must be an octet encoding (i.e.,
2361 rtl_isOctetTextEncoding(encoding) must return true).
2364 A combination of RTL_TEXTTOUNICODE_FLAGS that detail how to do the
2365 conversion (see rtl_convertTextToUnicode). RTL_TEXTTOUNICODE_FLAGS_FLUSH
2366 need not be included, it is implicitly assumed. Typical uses are either
2367 RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
2368 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
2369 RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR (fail if a byte or multi-byte sequence
2370 cannot be converted from the source encoding) or
2371 OSTRING_TO_OUSTRING_CVTFLAGS (make a best efforts conversion).
2374 True if the conversion succeeded, false otherwise.
2378 SAL_DLLPUBLIC sal_Bool SAL_CALL
rtl_convertStringToUString(
2379 rtl_uString
** target
, char const * source
, sal_Int32 length
,
2380 rtl_TextEncoding encoding
, sal_uInt32 flags
) SAL_THROW_EXTERN_C();
2382 /** Ensure a string has enough space for a given number of characters.
2384 If the given string is large enough and has refcount of 1, it is not altered in any way.
2385 Otherwise it is replaced by a copy that has enough space for the given number of characters,
2386 data from the source string is copied to the beginning of it, the content of the remaining
2387 capacity undefined, the string has refcount of 1, and refcount of the original string is decreased.
2390 pointer to the string. The pointed-to data must be a valid string.
2393 the number of characters
2395 @since LibreOffice 4.1
2398 SAL_DLLPUBLIC
void SAL_CALL
rtl_uString_ensureCapacity( rtl_uString
** str
, sal_Int32 size
) SAL_THROW_EXTERN_C();
2404 #endif // INCLUDED_RTL_USTRING_H
2406 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */