@@ -1303,49 +1303,65 @@ op.getlexrel = function(pad, name) {
1303
1303
1304
1304
1305
1305
op . bitand_s = function ( a , b ) {
1306
- let ret = '' ;
1307
- let i = 0 ;
1308
- while ( true ) {
1309
- const codepointA = a . codePointAt ( i ) ;
1310
- const codepointB = b . codePointAt ( i ) ;
1311
- if ( codepointA === undefined || codepointB == undefined ) {
1312
- return ret ;
1313
- }
1314
- ret += String . fromCodePoint ( codepointA & codepointB ) ;
1315
- i ++ ;
1306
+ const codePointsA = [ ]
1307
+ const codePointsB = [ ]
1308
+
1309
+ for ( const c of a . normalize ( 'NFC' ) ) {
1310
+ codePointsA . push ( c . codePointAt ( 0 ) ) ;
1311
+ }
1312
+ for ( const c of b . normalize ( 'NFC' ) ) {
1313
+ codePointsB . push ( c . codePointAt ( 0 ) ) ;
1314
+ }
1315
+
1316
+ const ret = [ ] ;
1317
+
1318
+ for ( let i = 0 ; i < codePointsA . length && i < codePointsB . length ; i ++ ) {
1319
+ ret . push ( codePointsA [ i ] & codePointsB [ i ] ) ;
1316
1320
}
1321
+
1322
+ return String . fromCodePoint . apply ( undefined , ret ) . normalize ( 'NFC' ) ;
1317
1323
} ;
1318
1324
1319
1325
op . bitor_s = function ( a , b ) {
1320
- let ret = '' ;
1321
- let i = 0 ;
1322
- while ( true ) {
1323
- let codepointA = a . codePointAt ( i ) ;
1324
- let codepointB = b . codePointAt ( i ) ;
1325
- if ( codepointA === undefined && codepointB == undefined ) {
1326
- return ret ;
1327
- }
1328
- if ( codepointA === undefined ) codepointA = 0 ;
1329
- if ( codepointB === undefined ) codepointB = 0 ;
1330
- ret += String . fromCodePoint ( codepointA | codepointB ) ;
1331
- i ++ ;
1326
+ const codePointsA = [ ]
1327
+ const codePointsB = [ ]
1328
+
1329
+ for ( const c of a . normalize ( 'NFC' ) ) {
1330
+ codePointsA . push ( c . codePointAt ( 0 ) ) ;
1331
+ }
1332
+ for ( const c of b . normalize ( 'NFC' ) ) {
1333
+ codePointsB . push ( c . codePointAt ( 0 ) ) ;
1334
+ }
1335
+
1336
+ const ret = [ ] ;
1337
+
1338
+ for ( let i = 0 ; i < codePointsA . length || i < codePointsB . length ; i ++ ) {
1339
+ ret . push ( ( codePointsA [ i ] || 0 ) | ( codePointsB [ i ] || 0 ) ) ;
1332
1340
}
1341
+
1342
+ return String . fromCodePoint . apply ( undefined , ret ) . normalize ( 'NFC' ) ;
1333
1343
} ;
1334
1344
1335
1345
op . bitxor_s = function ( a , b ) {
1336
- let ret = '' ;
1337
- let i = 0 ;
1338
- while ( true ) {
1339
- let codepointA = a . codePointAt ( i ) ;
1340
- let codepointB = b . codePointAt ( i ) ;
1341
- if ( codepointA === undefined && codepointB == undefined ) {
1342
- return ret ;
1343
- }
1344
- if ( codepointA === undefined ) codepointA = 0 ;
1345
- if ( codepointB === undefined ) codepointB = 0 ;
1346
- ret += String . fromCodePoint ( codepointA ^ codepointB ) ;
1347
- i ++ ;
1346
+ const codePointsA = [ ]
1347
+ const codePointsB = [ ]
1348
+
1349
+ for ( const c of a . normalize ( 'NFC' ) ) {
1350
+ codePointsA . push ( c . codePointAt ( 0 ) ) ;
1351
+ }
1352
+ for ( const c of b . normalize ( 'NFC' ) ) {
1353
+ codePointsB . push ( c . codePointAt ( 0 ) ) ;
1348
1354
}
1355
+
1356
+ const ret = [ ] ;
1357
+
1358
+ for ( let i = 0 ; i < codePointsA . length || i < codePointsB . length ; i ++ ) {
1359
+ ret . push ( ( codePointsA [ i ] || 0 ) ^ ( codePointsB [ i ] || 0 ) ) ;
1360
+ }
1361
+
1362
+
1363
+
1364
+ return String . fromCodePoint . apply ( undefined , ret ) . normalize ( 'NFC' ) ;
1349
1365
} ;
1350
1366
1351
1367
op . replace = function ( str , offset , count , repl ) {
0 commit comments