Summary: | ASTERISK-06492: Convert a string to lowercase/uppercase | ||
Reporter: | powerkill (powerkill) | Labels: | |
Date Opened: | 2006-03-07 07:17:48.000-0600 | Date Closed: | 2011-06-07 14:03:19 |
Priority: | Major | Regression? | No |
Status: | Closed/Complete | Components: | Functions/General |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) func_strings_last.patch.txt ( 1) func_strings.c.svn.patch ( 2) func_strings.patch.txt | |
Description: | Patch the file func_strings to add 2 functions LCASE and UCASE that convert to lowercase and uppercase respectively ****** ADDITIONAL INFORMATION ****** Example : exten => 1,1,Set(TECH=${CUT(CHANNEL|/|1)}) exten => 1,2,NoOP(${TECH}) exten => 1,3,Set(TECH=${LCASE(${TECH})}) exten => 1,4,NoOP(${TECH}) exten => 1,5,Set(TECH=${UCASE(${TECH})}) exten => 1,6,NoOP(${TECH}) -- Executing Set("IAX2/powerkill-2", "TECH=IAX2") in new stack -- Executing NoOp("IAX2/powerkill-2", "IAX2") in new stack -- Executing Set("IAX2/powerkill-2", "TECH=iax2") in new stack -- Executing NoOp("IAX2/powerkill-2", "iax2") in new stack -- Executing Set("IAX2/powerkill-2", "TECH=IAX2") in new stack -- Executing NoOp("IAX2/powerkill-2", "IAX2") in new stack | ||
Comments: | By: Tilghman Lesher (tilghman) 2006-03-07 07:31:14.000-0600 Please revise your patch to apply against trunk. There will be no new features in the 1.2 branch. By: Clod Patry (junky) 2006-03-07 07:35:48.000-0600 Please read the CODING-GUIDELINES. By: Olle Johansson (oej) 2006-03-07 09:11:24.000-0600 Does this work with many different character sets or only USASCII? Since we are moving towards UTF8, we need to documenet character set support for each new function that handles strings. By: Russell Bryant (russell) 2006-03-07 11:35:55.000-0600 I personally would prefer to name these TOUPPER() and TOLOWER(). By: powerkill (powerkill) 2006-03-07 11:45:35.000-0600 I'm OK to rename them for encoding I pay0 special attention to Western and Eastern European characters, which are not converted correctly by the toupper and tolower C runtime library functions. If the input is UTF-8, then latin characters are multibyte, and tolower/toupper will never have the chance to see the whole character (it only sees one byte at a time), so it won't work I will test against trunk asap By: Olle Johansson (oej) 2006-03-07 11:48:03.000-0600 Powerkill: Just make sure that you document how it works, whether or not it uses locale on the local system and how it handles utf8. By: Olle Johansson (oej) 2006-03-07 11:48:22.000-0600 Documents in the help text is what I mean. By: Tilghman Lesher (tilghman) 2006-03-07 13:56:09.000-0600 powerkill: if toupper(3) and tolower(3) are not correctly converting your Eastern European characters, it might be because you're using the wrong locale in your environment. Both of those glibc functions are designed to take advantage of the locale. In the default "C" locale, there are no conversions in the extended character set, but in other locales, there are. By: John Laur (gork) 2006-03-08 11:43:08.000-0600 Can we add a mixed case function to capitalize the first letter of each word following a space or punctuation? this would be enormously helpful for reformatting Caller ID sent from phone company. By: Clod Patry (junky) 2006-03-08 11:55:18.000-0600 you mean like the fonction ucfirst? http://ca3.php.net/manual/en/function.ucfirst.php By: John Laur (gork) 2006-03-08 12:42:10.000-0600 No; the function would be more like PHP's ucwords() function, capitalizing the first letter of each word. This would be better for names, converting "JOHN SMITH" to "John Smith" By: Tilghman Lesher (tilghman) 2006-03-08 12:59:25.000-0600 gork: if you want such a function, you can write it. There are way too many other cases where such capitalization does not give a desired result that this would quickly become a quagmire where everybody would expect the function to be customized to their own particular situations. The simple case which proves the point: Ibm Pc Support (where the correct capitalization would be IBM PC Support). By: powerkill (powerkill) 2006-03-16 15:07:10.000-0600 func_strings.c.svn.patch patch againt last SVN Rename function to toupper et tolower If other are interest I can create a function ucfirst that will capitalize first letter of each word. By: Russell Bryant (russell) 2006-03-16 21:11:27.000-0600 This patch still has some formatting issues: 1) Please use tabs instead of spaces for indentation. 2) Refer to the coding guidelines document for information about the preferred placement of braces. By: Olle Johansson (oej) 2006-03-18 05:17:01.000-0600 Added to test-this-branch with formatting changes By: Olle Johansson (oej) 2006-03-18 05:27:58.000-0600 - Needed to add include ctype.h for OS/X - All functions are static int, not static char * - The output is copied to buf Guess this was poorly tested, powerkill ;-) Check the code in test-this-branch, test it, and please upload a new patch. By: Tilghman Lesher (tilghman) 2006-03-24 22:58:40.000-0600 No response from reporter. Reopen if/when new patch ready. By: powerkill (powerkill) 2006-04-14 05:45:19 New patch By: powerkill (powerkill) 2006-04-14 05:46:39 I correct all oej advice, and test it on last svn trunk By: Tilghman Lesher (tilghman) 2006-04-15 00:51:26 Still not compliant with coding guidelines. By: Tilghman Lesher (tilghman) 2006-04-15 00:53:31 Reopen when you have actually read the coding guidelines and are ready to supply a patch which complies. By: Digium Subversion (svnbot) 2008-01-15 17:35:29.000-0600 Repository: asterisk Revision: 13392 U team/oej/test-this-branch/README.test-this-branch U team/oej/test-this-branch/funcs/func_strings.c ------------------------------------------------------------------------ r13392 | oej | 2008-01-15 17:35:28 -0600 (Tue, 15 Jan 2008) | 2 lines - Powerkill's toupper and tolower functions with some changes (ASTERISK-6492) ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=13392 |