From: "Iñaki Baz Castillo" Date: 2009-04-03T03:29:23+09:00 Subject: Re: String#capitalize more complex El Jueves 02 Abril 2009, trans escribió: > I would look at the camelcase implementations of Facets, English or > ActiveSupport. They are pretty close to what you want. You may even be > able to use one of them outright. Thanks, but finally I've decided to create a Ruby C extension for that. The code is very simple and fast: --------------------- /* * Capitalize each word of a header name. Examples: * - "record-route" => "Record-Route" * - "from" => "From" * - "VIA" => "Via" * */ char *string; int i; string = XXXXXX if ( string[0] >= 'a' && string[0] <= 'z' ) // 'a'=97, 'z'=122 string[0] -= 32; for (i=1; i= 'a' && string[i] <= 'z' ) string[i] -= 32; else if ( string[i] >= 'A' && string[i] <= 'Z' ) string[i] += 32; } -- Iñaki Baz Castillo