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 101133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:42:44+00:00 2026-05-11T00:42:44+00:00

How would you write ToUpper() if it didn’t exist? Bonus points for i18n and

  • 0

How would you write ToUpper() if it didn’t exist? Bonus points for i18n and L10n

Curiosity sparked by this: http://thedailywtf.com/Articles/The-Long-Way-toUpper.aspx

  • 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. 2026-05-11T00:42:45+00:00Added an answer on May 11, 2026 at 12:42 am
    1. I download the Unicode tables
    2. I import the tables into a database
    3. I write a method upper().

    Here is a sample implementation 😉

    public static String upper(String s) {     if (s == null) {         return null;     }      final int N = s.length(); // Mind the optimization!     PreparedStatement stmtName = null;     PreparedStatement stmtSmall = null;     ResultSet rsName = null;     ResultSet rsSmall = null;     StringBuilder buffer = new StringBuilder (N); // Much faster than StringBuffer!     try {         conn = DBFactory.getConnection();         stmtName = conn.prepareStatement('select name from unicode.chart where codepoint = ?');         // TODO Optimization: Maybe move this in the if() so we don't create this         // unless there are uppercase characters in the string.         stmtSmall = conn.prepareStatement('select codepoint from unicode.chart where name = ?');         for (int i=0; i<N; i++) {             int c = s.charAt(i);             stmtName.setInt(1, c);             rsName = stmtName.execute();             if (rsName.next()) {                 String name = rsName.getString(1);                 if (name.contains(' SMALL ')) {                     name = name.replaceAll(' SMALL ', ' CAPITAL ');                      stmtSmall.setString(1, name);                     rsSmall = stmtSmall.execute();                     if (rsSmall.next()) {                         c = rsSmall.getInt(1);                     }                      rsSmall = DBUtil.close(rsSmall);                 }             }             rsName = DBUtil.close(rsName);         }     }     finally {         // Always clean up         rsSmall = DBUtil.close(rsSmall);         rsName = DBUtil.close(rsName);         stmtSmall = DBUtil.close(stmtSmall);         stmtName = DBUtil.close(stmtName);     }      // TODO Optimization: Maybe read the table once into RAM at the start     // Would waste a lot of memory, though :/     return buffer.toString(); } 

    😉

    Note: The unicode charts which you can find on unicode.org contain the name of the character/code point. This string will contain ‘ SMALL ‘ for characters which are uppercase (mind the blanks or it might match ‘SMALLER’ and the like). Now, you can search for a similar name with ‘SMALL’ replaced with ‘CAPITAL’. If you find it, you’ve found the captial version.

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

Sidebar

Ask A Question

Stats

  • Questions 99k
  • Answers 99k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Perhaps this will work? SELECT ID, COALESCE(Col1, Col2, Col3) AS… May 11, 2026 at 7:45 pm
  • Editorial Team
    Editorial Team added an answer That is a synthetic accessor. Even inner classes don't really… May 11, 2026 at 7:45 pm
  • Editorial Team
    Editorial Team added an answer Most likely this is an uncaught exception. You might want… May 11, 2026 at 7:45 pm

Related Questions

How would you write ToUpper() if it didn't exist? Bonus points for i18n and
How would you write a regular expression to convert mark down into HTML? For
How would you write (in C/C++) a macro which tests if an integer type
Computer Haiku How would you write a program To make them for you
How would you prevent the user from adding or removing lines in a TextBox?

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.