From: "Iñaki Baz Castillo" Date: 2009-04-02T20:55:47+09:00 Subject: String#capitalize more complex Hi, I receive headers (the protocol syntax allows them being lowcase, upcase or a mix). For example, the following header names are equivalent: a) Record-Route b) record-route c) RECORD-ROUTE d) Record-ROUTE I'm trying to do a method to convert all of them to: Record-Route Basically what I need is to capitalize all the header name parts after splitting it using "-" as separator. I can do it as follows: ------------ hname = "Record-ROUTE" hname.split("-").map {|w| w.capitalize }.join("-") } => "Record-Route" ------------ Benchmark.realtime { hname.split("-").map {|w| w.capitalize }.join("-") } 1.69277191162109e-05 Is there any option even faster? I think it would be faster if I operate directly in the original string instead of doing "split" and "join" (since these last methods create more strings so allocate memory for them and so). I would prefer to do the modification "in place". BTW, could I know how to convert "a" char into "A"? I expected something as in c: 'a' + 1 => 'b' 'a' + ¿X? => 'A' but in Ruby#String I just find String#next which just increment the char in one unit ("a".next => "b"). Any suggestion? Thanks a lot. Thanks a lot. -- Iñaki Baz Castillo