And if you want to NOT modify the core mootools sources, and uppercase
initial accented words as well... place this somewhere in your code...


   1. String.implement({
   2.
   3.     ucapitalize: function(){
   4.         return this
   .replace(/(^|\s)[a-z\xC0-\xFF\u0100-\u024F\u1E00-\u1EFF]/g, function
   (match){
   5.             return match.toUpperCase();
   6.         });
   7.     }
   8.
   9. });


And use it like:

>> "érase una vez en américa".ucapitalize();
<< "Érase Una Vez En América"


On 10/30/08, nwhite <[EMAIL PROTECTED]> wrote:
>
> capitalize : function(){
>    return this.replace(/(^|\s)[a-z]/g,
>         function(A){
>             return A.toUpperCase();
>         }
>       );
> }
>
> Still matches multiple words and fixes the problem for me.
>
> On Thu, Oct 30, 2008 at 6:49 PM, evan <[EMAIL PROTECTED]> wrote:
>
>>
>> Could you just use text-transform:capitalize in your css to render the
>> text like you want?
>>
>> On Oct 30, 11:09 am, "Gerson Albuquerque" <[EMAIL PROTECTED]> wrote:
>> > Hi,
>> >
>> > I'm having the following problem:
>> >
>> > I'm using the function captalize, on this word: "memória", so I could
>> get it
>> > capitalized. The result that I'm getting on my site is "MemóRia", with
>> this
>> > capitalized "R". when it was supposed to capitalize only the first
>> letter. I
>> > think the problem is that it is not recognizing the "ó", and then it
>> thinks
>> > that the word has finished and capitalizes the letter R.
>> >
>> > Did I make myself clear? If so, please, someone can help me. I'm really
>> > stucked on this.
>> >
>> > The functions follows bellow:
>> >
>> > capitalize:function(){
>> > return this.replace(/\b[a-z]/g,
>> > function(A){
>> > return A.toUpperCase();
>> >
>> > }
>> > );
>> > }
>> >
>> > Thanks,
>> >
>> > Gerson Albuquerque
>>
>
>


-- 
◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦◦
Ivanicus' Code Box
http://ivanicus.com/

Reply via email to