Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1072727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:54:03+00:00 2026-05-16T20:54:03+00:00

The upcase method capitalizes the entire string, but I need to capitalize only the

  • 0

The upcase method capitalizes the entire string, but I need to capitalize only the first letter.

Also, I need to support several popular languages, like German and Russian.

How do I do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:54:04+00:00Added an answer on May 16, 2026 at 8:54 pm

    It depends on which Ruby version you use:

    Ruby 2.4 and higher:

    It just works, as since Ruby v2.4.0 supports Unicode case mapping:

    "мария".capitalize #=> Мария
    

    Ruby 2.3 and lower:

    "maria".capitalize #=> "Maria"
    "мария".capitalize #=> мария
    

    The problem is, it just doesn’t do what you want it to, it outputs мария instead of Мария.

    If you’re using Rails there’s an easy workaround:

    "мария".mb_chars.capitalize.to_s # requires ActiveSupport::Multibyte
    

    Otherwise, you’ll have to install the unicode gem and use it like this:

    require 'unicode'
    
    Unicode::capitalize("мария") #=> Мария
    

    Ruby 1.8:

    Be sure to use the coding magic comment:

    #!/usr/bin/env ruby
    
    puts "мария".capitalize
    

    gives invalid multibyte char (US-ASCII), while:

    #!/usr/bin/env ruby
    #coding: utf-8
    
    puts "мария".capitalize
    

    works without errors, but also see the “Ruby 2.3 and lower” section for real capitalization.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why can you chain this: Test.upcase.reverse.next.swapcase but not this: x = My_Class.new x.a.b.c where
I want to capitalize the first character of each word and leave the rest
Can you explain me what function of merge method here? it should reject email
I had to convert a series of sentences into camel-cased method names. I ended
class AddTitleToPosts < ActiveRecord::Migration def self.up add_column :posts, :title, :string Post.find(:all).each do |post| post.update(:title
I need to convert all values in a structure (arguments passed into a function)
So matz made the decision to keep upcase and downcase limited to /[A-Z]/i in
I am using the following code to compare strings but it always takes me
The other converts work, what do I need to do to get D) working
I wanted to write a snippet of ruby that would take a string and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.