bug-libunistring
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-libunistring] Re: case-mapping part of a Unicode string


From: Paolo Bonzini
Subject: [bug-libunistring] Re: case-mapping part of a Unicode string
Date: Tue, 30 Jun 2009 10:47:47 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1b3pre) Gecko/20090513 Fedora/3.0-2.3.beta2.fc11 Thunderbird/3.0b2

  size_t uppercased_part_3_4_len;
  uint8_t *uppercased_part_3_4 =
    u8_ct_toupper (pointer3, pointer4 - pointer3,
                   u8_casing_prefix_context (s, pointer3 - s),
                   u8_casing_suffix_context (pointer4, s_end - pointer4),
                   iso639_language, NULL, NULL, &uppercased_part_3_4_len);
  size_t uppercased_part_6_8_len;
  uint8_t *uppercased_part_6_8 =
    u8_ct_toupper (pointer6, pointer8 - pointer6,
                   u8_casing_prefix_context (s, pointer6 - s),
                   u8_casing_suffix_context (pointer8, s_end - pointer6),
                   iso639_language, NULL, NULL, &uppercased_part_6_8_len);

Regarding this part, how could I use the incremental context computation? I can imagine how to use u8_casing_prefixes_context, but not the same for suffixes:

  forgot_the_type_name pre = u8_casing_prefix_context (s, pointer3 - s);
  forgot_the_type_name suf = u8_casing_suffix_context (pointer4,
                                                       s_end - pointer4);
  size_t uppercased_part_3_4_len;
  uint8_t *uppercased_part_3_4 =
    u8_ct_toupper (pointer3, pointer4 - pointer3, pre, suf,
                   iso639_language, NULL, NULL,
                   &uppercased_part_3_4_len);

  pre = u8_casing_prefixes_context (pointer4, pointer6 - pointer4, pre);
  suf = u8_casing_suffix_context (pointer8, s_end - pointer8, suf);
  size_t uppercased_part_6_8_len;
  uint8_t *uppercased_part_6_8 =
    u8_ct_toupper (pointer6, pointer8 - pointer6, pre, suf,
                   iso639_language, NULL, NULL,
                   &uppercased_part_6_8_len);

Is this intentional? Does u8_casing_suffixes_context make sense only when scanning backwards?

If so, you should add something like: "u8_casing_prefixes_context is convenient if you are scanning a string forwards, while u8_casing_suffixes_context does the same function when scanning backwards. For the suffix context on forward scans you should just pass the entire remaining part of the string u8_casing_suffix_context, and likewise for the prefix context on backward scans."

(Note that in my case I have no control on the characters I ask you to case-fold; it may be that I ask you to case-fold a combining accent and only that).

> And finally use u8_normalize to normalize the result to NFC
> (optional, but recommended):

It would be nice to have something in coreutils doing normalization...

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]