Re: Proposal: add uloc_setKeywordValue and uloc_removeKeyword

George Rhoten <[email protected]> Tue, 24 Aug 2004 17:43:11 -0700
Newsgroups gmane.comp.lib.icu.general
Message-ID <OF4F4AE92B.B9CF99E4-ON86256EFB.000333A1-88256EFB.0003ECEA@us.ibm.com>
I like the single uloc_setKeywordValue() function idea.  It seems like 
less duplication of effort for removing keywords.

Regarding the question in the proposal, I presume that the keywords will 
be sorted to any rules that uloc_getName uses for keywords.

I presume that a Locale class API is not in this proposal, since we don't 
provide similar set functions for languages, scripts, countries or 
variants.

George Rhoten
IBM Globalization Center of Competency/ICU  San José, CA, USA
ICU main website: http://oss.software.ibm.com/icu/index.html



Deborah Goldsmith <[email protected]> 
Sent by: [email protected]
08/24/2004 05:00 PM

To
"Steven R. Loomis" <[email protected]>
cc
Icu <[email protected]>
Subject
Re: Proposal:  add uloc_setKeywordValue and uloc_removeKeyword






I don't know of a need for zero-length keyword values, I was just 
saying they could be accommodated if necessary. Yes, I was suggesting 
removing the removeKeyword function.

Deborah

On Aug 24, 2004, at 4:36 PM, Steven R. Loomis wrote:

> That's already in the proposal, but i think you mean a modification to 
> (1) allow 0-length values to be set and (2) remove the removeKeyword 
> function
>
> actually i am implementing remove as just calling set with a null
>
> I believe getKeywordValue returns 0 (length 0) for both a missing and 
> a 0-length value.   I'd rather not allow 0-length values in that case.
>
>>  * @param keywordValue value of the keyword to be set. If 0-length or
>>  *  NULL, will result in the keyword being removed.
>
>
> On 24-Awi-2004, at 9:44 PM, Deborah Goldsmith wrote:
>
>> A possible alternative: use a NULL keywordValue passed to 
>> uloc_setKeywordValue to mean "remove". I don't know if empty keyword 
>> values are allowed, but even if they are that can be distinguished 
>> from the case of the pointer being NULL.
>>
>> This makes the API a little smaller, if that's important. This is the 
>> way I did it in my own implementation.
>>
>> Deborah
>>
>> On Aug 24, 2004, at 10:26 AM, Steven R. Loomis wrote:
>>
>>>
>>> Proposal:  add uloc_setKeywordValue and uloc_deleteKeyword
>>> Date:    2004 Aug 24
>>> Bug: 3651 http://www.jtcsv.com/cgibin/icu-bugs?findid=3651
>>>
>>>  Quoting from the bug: "Since the UCalendarType argument to ucal_open
>>> is deprecated, there isn't a good way to set an explicit calendar to
>>> override the locale. By contrast, for a numeric format you can set 
>>> the
>>> currency programmatically.
>>>   "Provide functions in uloc.h for setting keywords as well as 
>>> getting
>>> them. Right now, you have to iterate through all the keywords 
>>> yourself
>>> to see if that keyword is already present (you don't want to set two
>>> copies of the same keyword). In addition to uloc_getKeywordValue
>>> there would be uloc_setKeywordValue and uloc_deleteKeyword."
>>>
>>> Q: should the keywords be sorted?
>>>
>>> /**
>>>  * Set the value of the specified keyword.
>>>  * NOTA BENE: Unlike almost every other ICU function which takes a
>>>  * buffer, this function will NOT truncate the output text. If a
>>>  * BUFFER_OVERFLOW_ERROR is received, it means that the original
>>>  * buffer is untouched. This is done to prevent incorrect or possibly
>>>  * even malformed locales from being generated and used.
>>>  * Missing keywords on delete won't be marked as an error.
>>>  *
>>>  * @param keywordName name of the keyword to be set. Case 
>>> insensitive.
>>>  * @param keywordValue value of the keyword to be set. If 0-length or
>>>  *  NULL, will result in the keyword being removed.
>>>  * @param buffer input buffer containing locale to be modified.
>>>  * @param bufferCapacity capacity of receiving buffer
>>>  * @param status containing error code - buffer not big enough.
>>>  * @return the length needed for the buffer
>>>  * @see uloc_removeKeyword
>>>  * @draft ICU 3.2
>>>  */
>>> U_DRAFT int32_t U_EXPORT2
>>> uloc_setKeywordValue(const char* keywordName,
>>>                      const char* keywordValue,
>>>                      char* buffer, int32_t bufferCapacity,
>>>                      UErrorCode* status);
>>>
>>>
>>> /**
>>>  * Remove a specified keyword.
>>>  * Missing keywords on delete won't be marked as an error.
>>>  * @param keywordName name of the keyword to be removed. Case 
>>> insensitive.
>>>  * @param buffer input buffer containing locale to be modified.
>>>  * @param bufferCapacity capacity of receiving buffer
>>>  * @param status containing error code - buffer not big enough.
>>>  * @return the length needed for the buffer
>>>  * @see uloc_removeKeyword
>>>  * @draft ICU 3.2
>>>  */
>>> U_DRAFT int32_t U_EXPORT2
>>> uloc_removeKeyword(const char* keywordName,
>>>                    char* buffer, int32_t bufferCapacity,
>>>                    UErrorCode* status);
>>>
>>> _______________________________________________
>>> icu mailing list
>>> [email protected]
>>> http://oss.software.ibm.com/developerworks/oss/mailman/listinfo/icu
>>
>> _______________________________________________
>> icu mailing list
>> [email protected]
>> http://oss.software.ibm.com/developerworks/oss/mailman/listinfo/icu
>

_______________________________________________
icu mailing list
[email protected]
http://oss.software.ibm.com/developerworks/oss/mailman/listinfo/icu