string
(canonical-composition (string->nfd string))))
-(define-integrable (string-nqc-maker cp-limit char-nqc?)
- (lambda (string)
- (let ((end (string-length string)))
- (let loop ((i 0) (last-ccc 0))
- (if (fix:< i end)
- (let ((char (string-ref string i)))
- (if (fix:< (char->integer char) cp-limit)
- (loop (fix:+ i 1) 0)
- (let ((ccc (ucd-ccc-value char)))
- (and (or (fix:= ccc 0) (fix:>= ccc last-ccc))
- (char-nqc? char)
- (loop (fix:+ i 1) ccc)))))
- #t)))))
-
-(define string-in-nfd? (string-nqc-maker #xC0 char-nfd-quick-check?))
-(define string-in-nfc? (string-nqc-maker #x300 char-nfc-quick-check?))
+(define-integrable (string-nqc-loop cp-limit char-nqc? sref)
+ (lambda (string start end)
+ (let loop ((i start) (last-ccc 0))
+ (if (fix:< i end)
+ (let ((char (sref string i)))
+ (if (fix:< (char->integer char) cp-limit)
+ (loop (fix:+ i 1) 0)
+ (let ((ccc (ucd-ccc-value char)))
+ (and (or (fix:= ccc 0) (fix:>= ccc last-ccc))
+ (char-nqc? char)
+ (loop (fix:+ i 1) ccc)))))
+ #t))))
+(define string-in-nfd?
+ (let ((legacy (string-nqc-loop #xC0 char-nfd-quick-check? legacy-string-ref))
+ (full (string-nqc-loop #xC0 char-nfd-quick-check? %full-string-ref)))
+ (lambda (string)
+ (receive (string start end)
+ (translate-slice string 0 (string-length string))
+ (if (legacy-string? string)
+ (legacy string start end)
+ (full string start end))))))
+
+(define string-in-nfc?
+ (let ((full (string-nqc-loop #x300 char-nfc-quick-check? %full-string-ref)))
+ (lambda (string)
+ (receive (string start end)
+ (translate-slice string 0 (string-length string))
+ (if (legacy-string? string)
+ #t
+ (full string start end))))))
+\f
(define (canonical-decomposition string)
(let ((end (string-length string))
(builder (string-builder '->nfc? #f)))