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 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

Related Questions

Somebody write this function void strToUpper(char *p) { while (*p) { *p = TOUPPER(*p);
So, In my old Linq-To-SQL I would write code like this var tableItem =
to bind something to an onChange event, one would write something similar to this:
normally to create an object you would write: function Dog(name) { this.name = name;
Can someone please help me understand how I would write this. If i am
This would write the output to a logfile: & $Env:WinDir\system32\inetsrv\appcmd.exe >test.log But what if
If I was to write a mocking library, how would this work (in other
I want to make my CMS work like this, if you would write certain
In Perl, I would write: $x = abbbc; $x =~ s/(b+)/z/; print Replaced $1
Do you know any library that will help doing that? I would write 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.