in reply to Re: Regexes for Case Change
in thread Regexes for Case Change

Ithink it's generally better to do this with the lc operator rather than tr since lc handles localisation character sets (Umlauts and so forth) and unicode properly.

Not that I think it matters in this case, but it's probably one of those things where when you get into one style you may as well get into the one which won't make you trip when you expand what you're working with.

Replies are listed 'Best First'.
Re: Re: Re: Regexes for Case Change
by jmcnamara (Monsignor) on May 08, 2002 at 13:28 UTC

    I think it's generally better to do this with the lc operator rather than tr since lc handles localisation character sets

    Only if "use locale" is in effect. Otherwise the following is unlikely to do anything:     print uc 'ü';

    This assertion also depends on what the "general" case is considered to be. The general case is probably a single character set so a transliteration, as shown by rob_au, is probably sufficient.

    --
    John.

Re: Re: Re: Regexes for Case Change
by rob_au (Abbot) on May 08, 2002 at 12:53 UTC
    While the perlfunc:tr operator may not handle localisation character sets, it does have the advantage over substitution of speed as it doesn't perform interpolation or use the regex engine. As such, the choice between functions really comes down to the data being manipulated and whether character and locale classes will come into effect.

    The transliteration solution was provided more so for proof of TMTOWTDI, YMMV.