-
-
Save FROGGS/61a3e002267bf54b1e42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MVMint64 MVM_string_equal_at_ignore_mark(MVMThreadContext *tc, MVMString *a, MVMString *b, MVMint64 offset) { | |
MVMNormalizer norm1; | |
MVMNormalizer norm2; | |
MVMGrapheme32 ga_nfd; | |
MVMGrapheme32 gb_nfd; | |
MVMint32 ready; | |
MVMGrapheme32 ga = MVM_string_get_grapheme_at_nocheck(tc, a, offset); | |
MVMGrapheme32 gb = MVM_string_get_grapheme_at_nocheck(tc, b, 0); | |
MVM_unicode_normalizer_init(tc, &norm1, MVM_NORMALIZE_NFD); | |
ready = MVM_unicode_normalizer_process_codepoint_to_grapheme(tc, &norm1, ga, &ga_nfd); | |
MVM_unicode_normalizer_eof(tc, &norm1); | |
if (!ready) | |
ga_nfd = MVM_unicode_normalizer_get_grapheme(tc, &norm1); | |
MVM_unicode_normalizer_init(tc, &norm2, MVM_NORMALIZE_NFD); | |
ready = MVM_unicode_normalizer_process_codepoint_to_grapheme(tc, &norm2, gb, &gb_nfd); | |
MVM_unicode_normalizer_eof(tc, &norm2); | |
if (!ready) | |
gb_nfd = MVM_unicode_normalizer_get_grapheme(tc, &norm2); | |
//~ fprintf(stderr, "MVM_string_equal_at_ignore_mark offset=%d %d == %d\n", offset, ga_nfd, gb_nfd); | |
return ga_nfd == gb_nfd ? 1 : 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment