Opened 12 years ago

Last modified 12 years ago

#4255 new enhancement

Add some simple case modification functions to the expression parser

Reported by: woodbri Owned by: sdlime
Priority: normal Milestone: 6.2 release
Component: MapServer C Library Version: svn-trunk (development)
Severity: normal Keywords:
Cc: dmorissette, tbonfort

Description

There is a need to be able to modify text strings being presented as labels. Some simple functions added to the expression parser would solve this problem.

initcap(string) - would force the first character to uppercase and the rest of the characters to lowere case for EACH word in the string.

upper(string) - would force all characters to uppercase

lower(string) - would force all characters to lowercase.

These functions should probably be UTF8 aware. Ideally they should be able to convert upper/lower case accented characters I believe there are functions in the ICU library that do this. Minimally, the functions should not damage UTF8 strings.

Change History (3)

comment:1 by dmorissette, 12 years ago

Cc: dmorissette added

See also ticket #1634 about essentially the same thing.

comment:2 by sdlime, 12 years ago

What library are we currently using for UTF8 strings elsewhere in the code? (consider me UTF8 illiterate) Note there's nothing in the expression handling (where these functions would be implemented) specific to UTF8 at all.

This addition would also aid simple string comparison in logical expressions...

Steve

comment:3 by woodbri, 12 years ago

Cc: tbonfort added

SteveL, I'm not sure we do much with UTF8 or Unicode. Thomas added some code in maptclutf.c to support mapcairo.c needs and we have some limited support for it in mapstring.c and a few other places where we need to support unicode or utf8.

I only mentioned libicu because I used it for another project where I needed to mess around with utf8 characters, otherwise, I'm pretty UTF8 illiterate too. It would probably be worth your time to spend 15 minutes on their web site. They also have a good example /usr/share/doc/libicu-dev/examples/case/ucase.c if you install the libicu-dev package on Debian.

I don't want to make this too complicated, my only concern is that as soon as we start doing case changes, we have to be aware of the encoding to do it correctly.

Note: See TracTickets for help on using tickets.