30 #include <nsStringGlue.h>
34 #include <CoreFoundation/CoreFoundation.h>
35 #include <Foundation/Foundation.h>
53 sbStringTransformImpl::NormalizeString(
const nsAString & aCharset,
54 PRUint32 aTransformFlags,
55 const nsAString & aInput,
61 NSMutableString *
str = [[NSMutableString alloc] initWithCharacters:aInput.BeginReading()
62 length:aInput.Length()];
65 NSString *lcaseStr = [str lowercaseString];
66 str = [NSString stringWithString:lcaseStr];
70 NSString *ucaseStr = [str uppercaseString];
71 str = [NSString stringWithString:ucaseStr];
77 [[NSMutableString alloc] initWithCharacters:aInput.BeginReading()
78 length:aInput.Length()];
81 CFStringTransform( (CFMutableStringRef)strCopy,
83 kCFStringTransformStripCombiningMarks,
88 for (
unsigned int i = 0;
i < [str length];
i++) {
89 if ([strCopy characterAtIndex:0] == [str characterAtIndex:
i]) {
90 [str replaceCharactersInRange:NSMakeRange(0, i)
99 CFStringTransform((CFMutableStringRef)str,
101 kCFStringTransformStripCombiningMarks,
106 const PRUnichar *original = (
const PRUnichar *)aInput.BeginReading();
110 NSCharacterSet *symbols = [NSCharacterSet symbolCharacterSet];
111 NSCharacterSet *alphaNumSet = [NSCharacterSet alphanumericCharacterSet];
112 PRBool bypassSymbolFiltering =
false;
113 PRBool bypassNonalnumFiltering =
false;
115 for(
unsigned int current = 0, optr = 0; current < [str length]; ++current, ++optr) {
116 if (bypassSymbolFiltering &&
117 bypassNonalnumFiltering)
120 unichar c = [str characterAtIndex:current];
123 PRInt32 numberLength;
125 if (numberLength > 0) {
126 current += numberLength-1;
127 optr += numberLength-1;
135 if (!bypassSymbolFiltering && (aTransformFlags & sbIStringTransform::TRANSFORM_IGNORE_SYMBOLS)) {
136 if([symbols characterIsMember:c]) {
137 [str replaceCharactersInRange:NSMakeRange(current--, 1) withString:@""];
140 bypassSymbolFiltering =
true;
145 if (!bypassNonalnumFiltering &&
146 ((aTransformFlags & sbIStringTransform::TRANSFORM_IGNORE_NONALPHANUM) ||
147 (aTransformFlags & sbIStringTransform::TRANSFORM_IGNORE_NONALPHANUM_IGNORE_SPACE))) {
148 if(![alphaNumSet characterIsMember:c] &&
149 ((c !=
' ') || (aTransformFlags & sbIStringTransform::TRANSFORM_IGNORE_NONALPHANUM_IGNORE_SPACE))) {
150 [str replaceCharactersInRange:NSMakeRange(current--, 1) withString:@""];
153 bypassNonalnumFiltering =
true;
159 NS_ASSERTION(original[optr] != 0,
"error with optr position tracking");
167 unichar *buf = (unichar *) malloc(
sizeof(unichar) * [str length]);
168 NS_ENSURE_TRUE(buf, NS_ERROR_OUT_OF_MEMORY);
170 [str getCharacters:buf];
172 _retval.Assign(buf, [str length]);
180 sbStringTransformImpl::ConvertToCharset(
const nsAString & aDestCharset,
181 const nsAString & aInput,
184 return NS_ERROR_NOT_IMPLEMENTED;
188 sbStringTransformImpl::GuessCharset(
const nsAString & aInput,
191 return NS_ERROR_NOT_IMPLEMENTED;
void SB_ExtractLeadingNumber(const CHARTYPE *str, PRBool *hasLeadingNumber, PRFloat64 *leadingNumber, PRInt32 *numberLength)
_getSelectedPageStyle s i