-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathunistr.h
More file actions
4440 lines (4023 loc) · 161 KB
/
unistr.h
File metadata and controls
4440 lines (4023 loc) · 161 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
**********************************************************************
* Copyright (C) 1998-2010, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*
* File unistr.h
*
* Modification History:
*
* Date Name Description
* 09/25/98 stephen Creation.
* 11/11/98 stephen Changed per 11/9 code review.
* 04/20/99 stephen Overhauled per 4/16 code review.
* 11/18/99 aliu Made to inherit from Replaceable. Added method
* handleReplaceBetween(); other methods unchanged.
* 06/25/01 grhoten Remove dependency on iostream.
******************************************************************************
*/
#ifndef UNISTR_H
#define UNISTR_H
/**
* \file
* \brief C++ API: Unicode String
*/
#include "unicode/utypes.h"
#include "unicode/rep.h"
#include "unicode/std_string.h"
#include "unicode/stringpiece.h"
#include "unicode/bytestream.h"
struct UConverter; // unicode/ucnv.h
class StringThreadTest;
#ifndef U_COMPARE_CODE_POINT_ORDER
/* see also ustring.h and unorm.h */
/**
* Option bit for u_strCaseCompare, u_strcasecmp, unorm_compare, etc:
* Compare strings in code point order instead of code unit order.
* @stable ICU 2.2
*/
#define U_COMPARE_CODE_POINT_ORDER 0x8000
#endif
#ifndef USTRING_H
/**
* \ingroup ustring_ustrlen
*/
U_STABLE int32_t U_EXPORT2
u_strlen(const UChar *s);
#endif
U_NAMESPACE_BEGIN
class Locale; // unicode/locid.h
class StringCharacterIterator;
class BreakIterator; // unicode/brkiter.h
/* The <iostream> include has been moved to unicode/ustream.h */
/**
* Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor
* which constructs a Unicode string from an invariant-character char * string.
* About invariant characters see utypes.h.
* This constructor has no runtime dependency on conversion code and is
* therefore recommended over ones taking a charset name string
* (where the empty string "" indicates invariant-character conversion).
*
* @stable ICU 3.2
*/
#define US_INV U_NAMESPACE_QUALIFIER UnicodeString::kInvariant
/**
* Unicode String literals in C++.
* Dependent on the platform properties, different UnicodeString
* constructors should be used to create a UnicodeString object from
* a string literal.
* The macros are defined for maximum performance.
* They work only for strings that contain "invariant characters", i.e.,
* only latin letters, digits, and some punctuation.
* See utypes.h for details.
*
* The string parameter must be a C string literal.
* The length of the string, not including the terminating
* <code>NUL</code>, must be specified as a constant.
* The U_STRING_DECL macro should be invoked exactly once for one
* such string variable before it is used.
* @stable ICU 2.0
*/
#if defined(U_DECLARE_UTF16)
# define UNICODE_STRING(cs, _length) U_NAMESPACE_QUALIFIER UnicodeString(TRUE, (const UChar *)U_DECLARE_UTF16(cs), _length)
#elif U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && (U_CHARSET_FAMILY==U_ASCII_FAMILY || (U_SIZEOF_UCHAR == 2 && defined(U_WCHAR_IS_UTF16)))
# define UNICODE_STRING(cs, _length) U_NAMESPACE_QUALIFIER UnicodeString(TRUE, (const UChar *)L ## cs, _length)
#elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY
# define UNICODE_STRING(cs, _length) U_NAMESPACE_QUALIFIER UnicodeString(TRUE, (const UChar *)cs, _length)
#else
# define UNICODE_STRING(cs, _length) U_NAMESPACE_QUALIFIER UnicodeString(cs, _length, US_INV)
#endif
/**
* Unicode String literals in C++.
* Dependent on the platform properties, different UnicodeString
* constructors should be used to create a UnicodeString object from
* a string literal.
* The macros are defined for improved performance.
* They work only for strings that contain "invariant characters", i.e.,
* only latin letters, digits, and some punctuation.
* See utypes.h for details.
*
* The string parameter must be a C string literal.
* @stable ICU 2.0
*/
#define UNICODE_STRING_SIMPLE(cs) UNICODE_STRING(cs, -1)
/**
* UnicodeString is a string class that stores Unicode characters directly and provides
* similar functionality as the Java String and StringBuffer classes.
* It is a concrete implementation of the abstract class Replaceable (for transliteration).
*
* The UnicodeString class is not suitable for subclassing.
*
* <p>For an overview of Unicode strings in C and C++ see the
* <a href="http://icu-project.org/userguide/strings.html">User Guide Strings chapter</a>.</p>
*
* <p>In ICU, a Unicode string consists of 16-bit Unicode <em>code units</em>.
* A Unicode character may be stored with either one code unit
* (the most common case) or with a matched pair of special code units
* ("surrogates"). The data type for code units is UChar.
* For single-character handling, a Unicode character code <em>point</em> is a value
* in the range 0..0x10ffff. ICU uses the UChar32 type for code points.</p>
*
* <p>Indexes and offsets into and lengths of strings always count code units, not code points.
* This is the same as with multi-byte char* strings in traditional string handling.
* Operations on partial strings typically do not test for code point boundaries.
* If necessary, the user needs to take care of such boundaries by testing for the code unit
* values or by using functions like
* UnicodeString::getChar32Start() and UnicodeString::getChar32Limit()
* (or, in C, the equivalent macros U16_SET_CP_START() and U16_SET_CP_LIMIT(), see utf.h).</p>
*
* UnicodeString methods are more lenient with regard to input parameter values
* than other ICU APIs. In particular:
* - If indexes are out of bounds for a UnicodeString object
* (<0 or >length()) then they are "pinned" to the nearest boundary.
* - If primitive string pointer values (e.g., const UChar * or char *)
* for input strings are NULL, then those input string parameters are treated
* as if they pointed to an empty string.
* However, this is <em>not</em> the case for char * parameters for charset names
* or other IDs.
* - Most UnicodeString methods do not take a UErrorCode parameter because
* there are usually very few opportunities for failure other than a shortage
* of memory, error codes in low-level C++ string methods would be inconvenient,
* and the error code as the last parameter (ICU convention) would prevent
* the use of default parameter values.
* Instead, such methods set the UnicodeString into a "bogus" state
* (see isBogus()) if an error occurs.
*
* In string comparisons, two UnicodeString objects that are both "bogus"
* compare equal (to be transitive and prevent endless loops in sorting),
* and a "bogus" string compares less than any non-"bogus" one.
*
* Const UnicodeString methods are thread-safe. Multiple threads can use
* const methods on the same UnicodeString object simultaneously,
* but non-const methods must not be called concurrently (in multiple threads)
* with any other (const or non-const) methods.
*
* Similarly, const UnicodeString & parameters are thread-safe.
* One object may be passed in as such a parameter concurrently in multiple threads.
* This includes the const UnicodeString & parameters for
* copy construction, assignment, and cloning.
*
* <p>UnicodeString uses several storage methods.
* String contents can be stored inside the UnicodeString object itself,
* in an allocated and shared buffer, or in an outside buffer that is "aliased".
* Most of this is done transparently, but careful aliasing in particular provides
* significant performance improvements.
* Also, the internal buffer is accessible via special functions.
* For details see the
* <a href="http://icu-project.org/userguide/strings.html">User Guide Strings chapter</a>.</p>
*
* @see utf.h
* @see CharacterIterator
* @stable ICU 2.0
*/
class U_COMMON_API UnicodeString : public Replaceable
{
public:
/**
* Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor
* which constructs a Unicode string from an invariant-character char * string.
* Use the macro US_INV instead of the full qualification for this value.
*
* @see US_INV
* @stable ICU 3.2
*/
enum EInvariant {
/**
* @see EInvariant
* @stable ICU 3.2
*/
kInvariant
};
//========================================
// Read-only operations
//========================================
/* Comparison - bitwise only - for international comparison use collation */
/**
* Equality operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
* @return TRUE if <TT>text</TT> contains the same characters as this one,
* FALSE otherwise.
* @stable ICU 2.0
*/
inline UBool operator== (const UnicodeString& text) const;
/**
* Inequality operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
* @return FALSE if <TT>text</TT> contains the same characters as this one,
* TRUE otherwise.
* @stable ICU 2.0
*/
inline UBool operator!= (const UnicodeString& text) const;
/**
* Greater than operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
* @return TRUE if the characters in this are bitwise
* greater than the characters in <code>text</code>, FALSE otherwise
* @stable ICU 2.0
*/
inline UBool operator> (const UnicodeString& text) const;
/**
* Less than operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
* @return TRUE if the characters in this are bitwise
* less than the characters in <code>text</code>, FALSE otherwise
* @stable ICU 2.0
*/
inline UBool operator< (const UnicodeString& text) const;
/**
* Greater than or equal operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
* @return TRUE if the characters in this are bitwise
* greater than or equal to the characters in <code>text</code>, FALSE otherwise
* @stable ICU 2.0
*/
inline UBool operator>= (const UnicodeString& text) const;
/**
* Less than or equal operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
* @return TRUE if the characters in this are bitwise
* less than or equal to the characters in <code>text</code>, FALSE otherwise
* @stable ICU 2.0
*/
inline UBool operator<= (const UnicodeString& text) const;
/**
* Compare the characters bitwise in this UnicodeString to
* the characters in <code>text</code>.
* @param text The UnicodeString to compare to this one.
* @return The result of bitwise character comparison: 0 if this
* contains the same characters as <code>text</code>, -1 if the characters in
* this are bitwise less than the characters in <code>text</code>, +1 if the
* characters in this are bitwise greater than the characters
* in <code>text</code>.
* @stable ICU 2.0
*/
inline int8_t compare(const UnicodeString& text) const;
/**
* Compare the characters bitwise in the range
* [<TT>start</TT>, <TT>start + length</TT>) with the characters
* in <TT>text</TT>
* @param start the offset at which the compare operation begins
* @param length the number of characters of text to compare.
* @param text the other text to be compared against this string.
* @return The result of bitwise character comparison: 0 if this
* contains the same characters as <code>text</code>, -1 if the characters in
* this are bitwise less than the characters in <code>text</code>, +1 if the
* characters in this are bitwise greater than the characters
* in <code>text</code>.
* @stable ICU 2.0
*/
inline int8_t compare(int32_t start,
int32_t length,
const UnicodeString& text) const;
/**
* Compare the characters bitwise in the range
* [<TT>start</TT>, <TT>start + length</TT>) with the characters
* in <TT>srcText</TT> in the range
* [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
* @param start the offset at which the compare operation begins
* @param length the number of characters in this to compare.
* @param srcText the text to be compared
* @param srcStart the offset into <TT>srcText</TT> to start comparison
* @param srcLength the number of characters in <TT>src</TT> to compare
* @return The result of bitwise character comparison: 0 if this
* contains the same characters as <code>srcText</code>, -1 if the characters in
* this are bitwise less than the characters in <code>srcText</code>, +1 if the
* characters in this are bitwise greater than the characters
* in <code>srcText</code>.
* @stable ICU 2.0
*/
inline int8_t compare(int32_t start,
int32_t length,
const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLength) const;
/**
* Compare the characters bitwise in this UnicodeString with the first
* <TT>srcLength</TT> characters in <TT>srcChars</TT>.
* @param srcChars The characters to compare to this UnicodeString.
* @param srcLength the number of characters in <TT>srcChars</TT> to compare
* @return The result of bitwise character comparison: 0 if this
* contains the same characters as <code>srcChars</code>, -1 if the characters in
* this are bitwise less than the characters in <code>srcChars</code>, +1 if the
* characters in this are bitwise greater than the characters
* in <code>srcChars</code>.
* @stable ICU 2.0
*/
inline int8_t compare(const UChar *srcChars,
int32_t srcLength) const;
/**
* Compare the characters bitwise in the range
* [<TT>start</TT>, <TT>start + length</TT>) with the first
* <TT>length</TT> characters in <TT>srcChars</TT>
* @param start the offset at which the compare operation begins
* @param length the number of characters to compare.
* @param srcChars the characters to be compared
* @return The result of bitwise character comparison: 0 if this
* contains the same characters as <code>srcChars</code>, -1 if the characters in
* this are bitwise less than the characters in <code>srcChars</code>, +1 if the
* characters in this are bitwise greater than the characters
* in <code>srcChars</code>.
* @stable ICU 2.0
*/
inline int8_t compare(int32_t start,
int32_t length,
const UChar *srcChars) const;
/**
* Compare the characters bitwise in the range
* [<TT>start</TT>, <TT>start + length</TT>) with the characters
* in <TT>srcChars</TT> in the range
* [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
* @param start the offset at which the compare operation begins
* @param length the number of characters in this to compare
* @param srcChars the characters to be compared
* @param srcStart the offset into <TT>srcChars</TT> to start comparison
* @param srcLength the number of characters in <TT>srcChars</TT> to compare
* @return The result of bitwise character comparison: 0 if this
* contains the same characters as <code>srcChars</code>, -1 if the characters in
* this are bitwise less than the characters in <code>srcChars</code>, +1 if the
* characters in this are bitwise greater than the characters
* in <code>srcChars</code>.
* @stable ICU 2.0
*/
inline int8_t compare(int32_t start,
int32_t length,
const UChar *srcChars,
int32_t srcStart,
int32_t srcLength) const;
/**
* Compare the characters bitwise in the range
* [<TT>start</TT>, <TT>limit</TT>) with the characters
* in <TT>srcText</TT> in the range
* [<TT>srcStart</TT>, <TT>srcLimit</TT>).
* @param start the offset at which the compare operation begins
* @param limit the offset immediately following the compare operation
* @param srcText the text to be compared
* @param srcStart the offset into <TT>srcText</TT> to start comparison
* @param srcLimit the offset into <TT>srcText</TT> to limit comparison
* @return The result of bitwise character comparison: 0 if this
* contains the same characters as <code>srcText</code>, -1 if the characters in
* this are bitwise less than the characters in <code>srcText</code>, +1 if the
* characters in this are bitwise greater than the characters
* in <code>srcText</code>.
* @stable ICU 2.0
*/
inline int8_t compareBetween(int32_t start,
int32_t limit,
const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLimit) const;
/**
* Compare two Unicode strings in code point order.
* The result may be different from the results of compare(), operator<, etc.
* if supplementary characters are present:
*
* In UTF-16, supplementary characters (with code points U+10000 and above) are
* stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
* which means that they compare as less than some other BMP characters like U+feff.
* This function compares Unicode strings in code point order.
* If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
*
* @param text Another string to compare this one to.
* @return a negative/zero/positive integer corresponding to whether
* this string is less than/equal to/greater than the second one
* in code point order
* @stable ICU 2.0
*/
inline int8_t compareCodePointOrder(const UnicodeString& text) const;
/**
* Compare two Unicode strings in code point order.
* The result may be different from the results of compare(), operator<, etc.
* if supplementary characters are present:
*
* In UTF-16, supplementary characters (with code points U+10000 and above) are
* stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
* which means that they compare as less than some other BMP characters like U+feff.
* This function compares Unicode strings in code point order.
* If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
*
* @param start The start offset in this string at which the compare operation begins.
* @param length The number of code units from this string to compare.
* @param srcText Another string to compare this one to.
* @return a negative/zero/positive integer corresponding to whether
* this string is less than/equal to/greater than the second one
* in code point order
* @stable ICU 2.0
*/
inline int8_t compareCodePointOrder(int32_t start,
int32_t length,
const UnicodeString& srcText) const;
/**
* Compare two Unicode strings in code point order.
* The result may be different from the results of compare(), operator<, etc.
* if supplementary characters are present:
*
* In UTF-16, supplementary characters (with code points U+10000 and above) are
* stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
* which means that they compare as less than some other BMP characters like U+feff.
* This function compares Unicode strings in code point order.
* If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
*
* @param start The start offset in this string at which the compare operation begins.
* @param length The number of code units from this string to compare.
* @param srcText Another string to compare this one to.
* @param srcStart The start offset in that string at which the compare operation begins.
* @param srcLength The number of code units from that string to compare.
* @return a negative/zero/positive integer corresponding to whether
* this string is less than/equal to/greater than the second one
* in code point order
* @stable ICU 2.0
*/
inline int8_t compareCodePointOrder(int32_t start,
int32_t length,
const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLength) const;
/**
* Compare two Unicode strings in code point order.
* The result may be different from the results of compare(), operator<, etc.
* if supplementary characters are present:
*
* In UTF-16, supplementary characters (with code points U+10000 and above) are
* stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
* which means that they compare as less than some other BMP characters like U+feff.
* This function compares Unicode strings in code point order.
* If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
*
* @param srcChars A pointer to another string to compare this one to.
* @param srcLength The number of code units from that string to compare.
* @return a negative/zero/positive integer corresponding to whether
* this string is less than/equal to/greater than the second one
* in code point order
* @stable ICU 2.0
*/
inline int8_t compareCodePointOrder(const UChar *srcChars,
int32_t srcLength) const;
/**
* Compare two Unicode strings in code point order.
* The result may be different from the results of compare(), operator<, etc.
* if supplementary characters are present:
*
* In UTF-16, supplementary characters (with code points U+10000 and above) are
* stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
* which means that they compare as less than some other BMP characters like U+feff.
* This function compares Unicode strings in code point order.
* If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
*
* @param start The start offset in this string at which the compare operation begins.
* @param length The number of code units from this string to compare.
* @param srcChars A pointer to another string to compare this one to.
* @return a negative/zero/positive integer corresponding to whether
* this string is less than/equal to/greater than the second one
* in code point order
* @stable ICU 2.0
*/
inline int8_t compareCodePointOrder(int32_t start,
int32_t length,
const UChar *srcChars) const;
/**
* Compare two Unicode strings in code point order.
* The result may be different from the results of compare(), operator<, etc.
* if supplementary characters are present:
*
* In UTF-16, supplementary characters (with code points U+10000 and above) are
* stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
* which means that they compare as less than some other BMP characters like U+feff.
* This function compares Unicode strings in code point order.
* If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
*
* @param start The start offset in this string at which the compare operation begins.
* @param length The number of code units from this string to compare.
* @param srcChars A pointer to another string to compare this one to.
* @param srcStart The start offset in that string at which the compare operation begins.
* @param srcLength The number of code units from that string to compare.
* @return a negative/zero/positive integer corresponding to whether
* this string is less than/equal to/greater than the second one
* in code point order
* @stable ICU 2.0
*/
inline int8_t compareCodePointOrder(int32_t start,
int32_t length,
const UChar *srcChars,
int32_t srcStart,
int32_t srcLength) const;
/**
* Compare two Unicode strings in code point order.
* The result may be different from the results of compare(), operator<, etc.
* if supplementary characters are present:
*
* In UTF-16, supplementary characters (with code points U+10000 and above) are
* stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
* which means that they compare as less than some other BMP characters like U+feff.
* This function compares Unicode strings in code point order.
* If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
*
* @param start The start offset in this string at which the compare operation begins.
* @param limit The offset after the last code unit from this string to compare.
* @param srcText Another string to compare this one to.
* @param srcStart The start offset in that string at which the compare operation begins.
* @param srcLimit The offset after the last code unit from that string to compare.
* @return a negative/zero/positive integer corresponding to whether
* this string is less than/equal to/greater than the second one
* in code point order
* @stable ICU 2.0
*/
inline int8_t compareCodePointOrderBetween(int32_t start,
int32_t limit,
const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLimit) const;
/**
* Compare two strings case-insensitively using full case folding.
* This is equivalent to this->foldCase(options).compare(text.foldCase(options)).
*
* @param text Another string to compare this one to.
* @param options A bit set of options:
* - U_FOLD_CASE_DEFAULT or 0 is used for default options:
* Comparison in code unit order with default case folding.
*
* - U_COMPARE_CODE_POINT_ORDER
* Set to choose code point order instead of code unit order
* (see u_strCompare for details).
*
* - U_FOLD_CASE_EXCLUDE_SPECIAL_I
*
* @return A negative, zero, or positive integer indicating the comparison result.
* @stable ICU 2.0
*/
inline int8_t caseCompare(const UnicodeString& text, uint32_t options) const;
/**
* Compare two strings case-insensitively using full case folding.
* This is equivalent to this->foldCase(options).compare(srcText.foldCase(options)).
*
* @param start The start offset in this string at which the compare operation begins.
* @param length The number of code units from this string to compare.
* @param srcText Another string to compare this one to.
* @param options A bit set of options:
* - U_FOLD_CASE_DEFAULT or 0 is used for default options:
* Comparison in code unit order with default case folding.
*
* - U_COMPARE_CODE_POINT_ORDER
* Set to choose code point order instead of code unit order
* (see u_strCompare for details).
*
* - U_FOLD_CASE_EXCLUDE_SPECIAL_I
*
* @return A negative, zero, or positive integer indicating the comparison result.
* @stable ICU 2.0
*/
inline int8_t caseCompare(int32_t start,
int32_t length,
const UnicodeString& srcText,
uint32_t options) const;
/**
* Compare two strings case-insensitively using full case folding.
* This is equivalent to this->foldCase(options).compare(srcText.foldCase(options)).
*
* @param start The start offset in this string at which the compare operation begins.
* @param length The number of code units from this string to compare.
* @param srcText Another string to compare this one to.
* @param srcStart The start offset in that string at which the compare operation begins.
* @param srcLength The number of code units from that string to compare.
* @param options A bit set of options:
* - U_FOLD_CASE_DEFAULT or 0 is used for default options:
* Comparison in code unit order with default case folding.
*
* - U_COMPARE_CODE_POINT_ORDER
* Set to choose code point order instead of code unit order
* (see u_strCompare for details).
*
* - U_FOLD_CASE_EXCLUDE_SPECIAL_I
*
* @return A negative, zero, or positive integer indicating the comparison result.
* @stable ICU 2.0
*/
inline int8_t caseCompare(int32_t start,
int32_t length,
const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLength,
uint32_t options) const;
/**
* Compare two strings case-insensitively using full case folding.
* This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).
*
* @param srcChars A pointer to another string to compare this one to.
* @param srcLength The number of code units from that string to compare.
* @param options A bit set of options:
* - U_FOLD_CASE_DEFAULT or 0 is used for default options:
* Comparison in code unit order with default case folding.
*
* - U_COMPARE_CODE_POINT_ORDER
* Set to choose code point order instead of code unit order
* (see u_strCompare for details).
*
* - U_FOLD_CASE_EXCLUDE_SPECIAL_I
*
* @return A negative, zero, or positive integer indicating the comparison result.
* @stable ICU 2.0
*/
inline int8_t caseCompare(const UChar *srcChars,
int32_t srcLength,
uint32_t options) const;
/**
* Compare two strings case-insensitively using full case folding.
* This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).
*
* @param start The start offset in this string at which the compare operation begins.
* @param length The number of code units from this string to compare.
* @param srcChars A pointer to another string to compare this one to.
* @param options A bit set of options:
* - U_FOLD_CASE_DEFAULT or 0 is used for default options:
* Comparison in code unit order with default case folding.
*
* - U_COMPARE_CODE_POINT_ORDER
* Set to choose code point order instead of code unit order
* (see u_strCompare for details).
*
* - U_FOLD_CASE_EXCLUDE_SPECIAL_I
*
* @return A negative, zero, or positive integer indicating the comparison result.
* @stable ICU 2.0
*/
inline int8_t caseCompare(int32_t start,
int32_t length,
const UChar *srcChars,
uint32_t options) const;
/**
* Compare two strings case-insensitively using full case folding.
* This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).
*
* @param start The start offset in this string at which the compare operation begins.
* @param length The number of code units from this string to compare.
* @param srcChars A pointer to another string to compare this one to.
* @param srcStart The start offset in that string at which the compare operation begins.
* @param srcLength The number of code units from that string to compare.
* @param options A bit set of options:
* - U_FOLD_CASE_DEFAULT or 0 is used for default options:
* Comparison in code unit order with default case folding.
*
* - U_COMPARE_CODE_POINT_ORDER
* Set to choose code point order instead of code unit order
* (see u_strCompare for details).
*
* - U_FOLD_CASE_EXCLUDE_SPECIAL_I
*
* @return A negative, zero, or positive integer indicating the comparison result.
* @stable ICU 2.0
*/
inline int8_t caseCompare(int32_t start,
int32_t length,
const UChar *srcChars,
int32_t srcStart,
int32_t srcLength,
uint32_t options) const;
/**
* Compare two strings case-insensitively using full case folding.
* This is equivalent to this->foldCase(options).compareBetween(text.foldCase(options)).
*
* @param start The start offset in this string at which the compare operation begins.
* @param limit The offset after the last code unit from this string to compare.
* @param srcText Another string to compare this one to.
* @param srcStart The start offset in that string at which the compare operation begins.
* @param srcLimit The offset after the last code unit from that string to compare.
* @param options A bit set of options:
* - U_FOLD_CASE_DEFAULT or 0 is used for default options:
* Comparison in code unit order with default case folding.
*
* - U_COMPARE_CODE_POINT_ORDER
* Set to choose code point order instead of code unit order
* (see u_strCompare for details).
*
* - U_FOLD_CASE_EXCLUDE_SPECIAL_I
*
* @return A negative, zero, or positive integer indicating the comparison result.
* @stable ICU 2.0
*/
inline int8_t caseCompareBetween(int32_t start,
int32_t limit,
const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLimit,
uint32_t options) const;
/**
* Determine if this starts with the characters in <TT>text</TT>
* @param text The text to match.
* @return TRUE if this starts with the characters in <TT>text</TT>,
* FALSE otherwise
* @stable ICU 2.0
*/
inline UBool startsWith(const UnicodeString& text) const;
/**
* Determine if this starts with the characters in <TT>srcText</TT>
* in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
* @param srcText The text to match.
* @param srcStart the offset into <TT>srcText</TT> to start matching
* @param srcLength the number of characters in <TT>srcText</TT> to match
* @return TRUE if this starts with the characters in <TT>text</TT>,
* FALSE otherwise
* @stable ICU 2.0
*/
inline UBool startsWith(const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLength) const;
/**
* Determine if this starts with the characters in <TT>srcChars</TT>
* @param srcChars The characters to match.
* @param srcLength the number of characters in <TT>srcChars</TT>
* @return TRUE if this starts with the characters in <TT>srcChars</TT>,
* FALSE otherwise
* @stable ICU 2.0
*/
inline UBool startsWith(const UChar *srcChars,
int32_t srcLength) const;
/**
* Determine if this ends with the characters in <TT>srcChars</TT>
* in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
* @param srcChars The characters to match.
* @param srcStart the offset into <TT>srcText</TT> to start matching
* @param srcLength the number of characters in <TT>srcChars</TT> to match
* @return TRUE if this ends with the characters in <TT>srcChars</TT>, FALSE otherwise
* @stable ICU 2.0
*/
inline UBool startsWith(const UChar *srcChars,
int32_t srcStart,
int32_t srcLength) const;
/**
* Determine if this ends with the characters in <TT>text</TT>
* @param text The text to match.
* @return TRUE if this ends with the characters in <TT>text</TT>,
* FALSE otherwise
* @stable ICU 2.0
*/
inline UBool endsWith(const UnicodeString& text) const;
/**
* Determine if this ends with the characters in <TT>srcText</TT>
* in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
* @param srcText The text to match.
* @param srcStart the offset into <TT>srcText</TT> to start matching
* @param srcLength the number of characters in <TT>srcText</TT> to match
* @return TRUE if this ends with the characters in <TT>text</TT>,
* FALSE otherwise
* @stable ICU 2.0
*/
inline UBool endsWith(const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLength) const;
/**
* Determine if this ends with the characters in <TT>srcChars</TT>
* @param srcChars The characters to match.
* @param srcLength the number of characters in <TT>srcChars</TT>
* @return TRUE if this ends with the characters in <TT>srcChars</TT>,
* FALSE otherwise
* @stable ICU 2.0
*/
inline UBool endsWith(const UChar *srcChars,
int32_t srcLength) const;
/**
* Determine if this ends with the characters in <TT>srcChars</TT>
* in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
* @param srcChars The characters to match.
* @param srcStart the offset into <TT>srcText</TT> to start matching
* @param srcLength the number of characters in <TT>srcChars</TT> to match
* @return TRUE if this ends with the characters in <TT>srcChars</TT>,
* FALSE otherwise
* @stable ICU 2.0
*/
inline UBool endsWith(const UChar *srcChars,
int32_t srcStart,
int32_t srcLength) const;
/* Searching - bitwise only */
/**
* Locate in this the first occurrence of the characters in <TT>text</TT>,
* using bitwise comparison.
* @param text The text to search for.
* @return The offset into this of the start of <TT>text</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
inline int32_t indexOf(const UnicodeString& text) const;
/**
* Locate in this the first occurrence of the characters in <TT>text</TT>
* starting at offset <TT>start</TT>, using bitwise comparison.
* @param text The text to search for.
* @param start The offset at which searching will start.
* @return The offset into this of the start of <TT>text</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
inline int32_t indexOf(const UnicodeString& text,
int32_t start) const;
/**
* Locate in this the first occurrence in the range
* [<TT>start</TT>, <TT>start + length</TT>) of the characters
* in <TT>text</TT>, using bitwise comparison.
* @param text The text to search for.
* @param start The offset at which searching will start.
* @param length The number of characters to search
* @return The offset into this of the start of <TT>text</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
inline int32_t indexOf(const UnicodeString& text,
int32_t start,
int32_t length) const;
/**
* Locate in this the first occurrence in the range
* [<TT>start</TT>, <TT>start + length</TT>) of the characters
* in <TT>srcText</TT> in the range
* [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),
* using bitwise comparison.
* @param srcText The text to search for.
* @param srcStart the offset into <TT>srcText</TT> at which
* to start matching
* @param srcLength the number of characters in <TT>srcText</TT> to match
* @param start the offset into this at which to start matching
* @param length the number of characters in this to search
* @return The offset into this of the start of <TT>text</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
inline int32_t indexOf(const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLength,
int32_t start,
int32_t length) const;
/**
* Locate in this the first occurrence of the characters in
* <TT>srcChars</TT>
* starting at offset <TT>start</TT>, using bitwise comparison.
* @param srcChars The text to search for.
* @param srcLength the number of characters in <TT>srcChars</TT> to match
* @param start the offset into this at which to start matching
* @return The offset into this of the start of <TT>text</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
inline int32_t indexOf(const UChar *srcChars,
int32_t srcLength,
int32_t start) const;
/**
* Locate in this the first occurrence in the range
* [<TT>start</TT>, <TT>start + length</TT>) of the characters
* in <TT>srcChars</TT>, using bitwise comparison.
* @param srcChars The text to search for.
* @param srcLength the number of characters in <TT>srcChars</TT>
* @param start The offset at which searching will start.
* @param length The number of characters to search
* @return The offset into this of the start of <TT>srcChars</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
inline int32_t indexOf(const UChar *srcChars,
int32_t srcLength,
int32_t start,
int32_t length) const;
/**
* Locate in this the first occurrence in the range
* [<TT>start</TT>, <TT>start + length</TT>) of the characters
* in <TT>srcChars</TT> in the range
* [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),
* using bitwise comparison.
* @param srcChars The text to search for.
* @param srcStart the offset into <TT>srcChars</TT> at which
* to start matching
* @param srcLength the number of characters in <TT>srcChars</TT> to match
* @param start the offset into this at which to start matching
* @param length the number of characters in this to search
* @return The offset into this of the start of <TT>text</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
int32_t indexOf(const UChar *srcChars,
int32_t srcStart,
int32_t srcLength,
int32_t start,
int32_t length) const;
/**
* Locate in this the first occurrence of the BMP code point <code>c</code>,
* using bitwise comparison.
* @param c The code unit to search for.
* @return The offset into this of <TT>c</TT>, or -1 if not found.
* @stable ICU 2.0
*/
inline int32_t indexOf(UChar c) const;
/**
* Locate in this the first occurrence of the code point <TT>c</TT>,
* using bitwise comparison.
*
* @param c The code point to search for.
* @return The offset into this of <TT>c</TT>, or -1 if not found.
* @stable ICU 2.0
*/
inline int32_t indexOf(UChar32 c) const;
/**
* Locate in this the first occurrence of the BMP code point <code>c</code>,
* starting at offset <TT>start</TT>, using bitwise comparison.
* @param c The code unit to search for.
* @param start The offset at which searching will start.
* @return The offset into this of <TT>c</TT>, or -1 if not found.
* @stable ICU 2.0
*/
inline int32_t indexOf(UChar c,
int32_t start) const;
/**
* Locate in this the first occurrence of the code point <TT>c</TT>
* starting at offset <TT>start</TT>, using bitwise comparison.
*
* @param c The code point to search for.
* @param start The offset at which searching will start.
* @return The offset into this of <TT>c</TT>, or -1 if not found.
* @stable ICU 2.0
*/
inline int32_t indexOf(UChar32 c,
int32_t start) const;
/**