MCPcopy Create free account
hub / github.com/aboSamoor/pycld2 / LowerScriptSpan

Method LowerScriptSpan

cld2/internal/getonescriptspan.cc:1035–1056  ·  view source on GitHub ↗

Force Latin, Cyrillic, Armenian, Greek scripts to be lowercase List changes with each version of Unicode, so just always lowercase Unicode 6.2.0: ARMENIAN COPTIC CYRILLIC DESERET GEORGIAN GLAGOLITIC GREEK LATIN

Source from the content-addressed store, hash-verified

1033// Unicode 6.2.0:
1034// ARMENIAN COPTIC CYRILLIC DESERET GEORGIAN GLAGOLITIC GREEK LATIN
1035void ScriptScanner::LowerScriptSpan(LangSpan* span) {
1036 // If needed, lowercase all the text. If we do it sooner, might miss
1037 // lowercasing an entity such as Á
1038 // We only need to do this for Latn and Cyrl scripts
1039 map2uplow_.Clear();
1040 // Full Unicode lowercase of the entire buffer, including
1041 // four pad bytes off the end.
1042 // Ahhh. But the last byte 0x00 is not interchange-valid, so we do 3 pad
1043 // bytes and put the 0x00 in explicitly.
1044 // Build an offset map from script_buffer_lower_ back to script_buffer_
1045 int consumed, filled, changed;
1046 StringPiece istr(span->text, span->text_bytes + 3);
1047 StringPiece ostr(script_buffer_lower_, kMaxScriptLowerBuffer);
1048
1049 UTF8GenericReplace(&utf8repl_lettermarklower_obj,
1050 istr, ostr, is_plain_text_,
1051 &consumed, &filled, &changed, &map2uplow_);
1052 script_buffer_lower_[filled] = '\0';
1053 span->text = script_buffer_lower_;
1054 span->text_bytes = filled - 3;
1055 map2uplow_.Reset();
1056}
1057
1058// Copy next run of same-script non-tag letters to buffer [NUL terminated]
1059// Force Latin, Cyrillic, Greek scripts to be lowercase

Callers

nothing calls this directly

Calls 3

UTF8GenericReplaceFunction · 0.85
ClearMethod · 0.80
ResetMethod · 0.80

Tested by

no test coverage detected