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

  • Home
  • SEARCH
  • 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

Let's say I want some instance of String behave differently from other, normal instances
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'm trying to understand how grep works in this example. The code works but
Does anyone have a trusted Proper Case or PCase algorithm (similar to a UCase
I'm currently reading Agile Web Development With Rails, 3rd edition. On page 672, I
def test_method [a, b, c].map {|i| yield(i) } end If I call test_method like
I'd like to replace each value in a hash with value.some_method . For example,
I want to convert the title of a page to a friendly URL and
I have a class with a constant defined for it. I then have a

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.