MCPcopy Create free account
hub / github.com/NativeScript/android / compose

Function compose

test-app/runtime/src/main/cpp/ada/ada.cpp:7893–7972  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7891}
7892
7893void compose(std::u32string& input) {
7894 /**
7895 * Compose the domain_name string to Unicode Normalization Form C.
7896 * @see https://www.unicode.org/reports/tr46/#ProcessingStepCompose
7897 */
7898 size_t input_count{0};
7899 size_t composition_count{0};
7900 for (; input_count < input.size(); input_count++, composition_count++) {
7901 input[composition_count] = input[input_count];
7902 if (input[input_count] >= hangul_lbase &&
7903 input[input_count] < hangul_lbase + hangul_lcount) {
7904 if (input_count + 1 < input.size() &&
7905 input[input_count + 1] >= hangul_vbase &&
7906 input[input_count + 1] < hangul_vbase + hangul_vcount) {
7907 input[composition_count] =
7908 hangul_sbase +
7909 ((input[input_count] - hangul_lbase) * hangul_vcount +
7910 input[input_count + 1] - hangul_vbase) *
7911 hangul_tcount;
7912 input_count++;
7913 if (input_count + 1 < input.size() &&
7914 input[input_count + 1] > hangul_tbase &&
7915 input[input_count + 1] < hangul_tbase + hangul_tcount) {
7916 input[composition_count] += input[++input_count] - hangul_tbase;
7917 }
7918 }
7919 } else if (input[input_count] >= hangul_sbase &&
7920 input[input_count] < hangul_sbase + hangul_scount) {
7921 if ((input[input_count] - hangul_sbase) % hangul_tcount &&
7922 input_count + 1 < input.size() &&
7923 input[input_count + 1] > hangul_tbase &&
7924 input[input_count + 1] < hangul_tbase + hangul_tcount) {
7925 input[composition_count] += input[++input_count] - hangul_tbase;
7926 }
7927 } else if (input[input_count] < 0x110000) {
7928 const uint16_t* composition =
7929 &composition_block[composition_index[input[input_count] >> 8]]
7930 [input[input_count] % 256];
7931 size_t initial_composition_count = composition_count;
7932 for (int32_t previous_ccc = -1; input_count + 1 < input.size();
7933 input_count++) {
7934 uint8_t ccc = get_ccc(input[input_count + 1]);
7935
7936 if (composition[1] != composition[0] && previous_ccc < ccc) {
7937 // Try finding a composition.
7938 int left = composition[0];
7939 int right = composition[1];
7940 while (left + 2 < right) {
7941 // mean without overflow
7942 int middle = left + (((right - left) >> 1) & ~1);
7943 if (composition_data[middle] <= input[input_count + 1]) {
7944 left = middle;
7945 }
7946 if (composition_data[middle] >= input[input_count + 1]) {
7947 right = middle;
7948 }
7949 }
7950 if (composition_data[left] == input[input_count + 1]) {

Callers 1

normalizeFunction · 0.85

Calls 2

get_cccFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected