@@ -105,6 +105,41 @@ public void applyAllCaseFold(int flag, ApplyAllCaseFoldFunction fun, Object arg)
105
105
return asciiCaseFoldCodesByString (flag , bytes , p , end );
106
106
}
107
107
108
+ /** onigenc_ascii_only_case_map / onigenc_single_byte_ascii_only_case_map
109
+ */
110
+ int asciiOnlyCaseMap (IntHolder flagP , byte []bytes , IntHolder pp , int end , byte []to , int toP , int toEnd ) {
111
+ int toStart = toP ;
112
+ int flags = flagP .value ;
113
+
114
+ while (pp .value < end && toP < toEnd ) {
115
+ // specialize for singlebyte ?
116
+ int length = length (bytes , pp .value , end );
117
+ if (length < 0 ) return length ;
118
+ int code = mbcToCode (bytes , pp .value , end ) & 0xff ;
119
+ pp .value += length ;
120
+
121
+ if (code >= 'a' && code <= 'z' && ((flags & Config .CASE_UPCASE ) != 0 )) {
122
+ flags |= Config .CASE_MODIFIED ;
123
+ code += 'A' - 'a' ;
124
+ } else if (code >= 'A' && code <= 'Z' && ((flags & Config .CASE_DOWNCASE | Config .CASE_FOLD ) != 0 )) {
125
+ flags |= Config .CASE_MODIFIED ;
126
+ code += 'a' - 'A' ;
127
+ }
128
+ to [toP ++] = (byte )code ;
129
+ if ((flags & Config .CASE_TITLECASE ) != 0 ) {
130
+ flags ^= (Config .CASE_UPCASE | Config .CASE_DOWNCASE | Config .CASE_TITLECASE );
131
+ }
132
+ }
133
+ flagP .value = flags ;
134
+ return toP - toStart ;
135
+ }
136
+
137
+ @ Override
138
+ public int caseMap (IntHolder flagP , byte [] bytes , IntHolder pp , int end , byte [] to , int toP , int toEnd ) {
139
+ return asciiOnlyCaseMap (flagP , bytes , pp , end , to , toP , toEnd );
140
+ }
141
+
142
+
108
143
/** onigenc_minimum_property_name_to_ctype
109
144
* notably overridden by unicode encodings
110
145
*/
0 commit comments