6

I tried using toUppercase() method to convert japanese characters to uppercase but it return same string with out conversion.

Is there any other way to do this using jquery or javascript.

fieldValue = "ショウコ";              //japanese string.

function convertToUppercase(fieldValue)
{      
 convertedValue = fieldValue.toUpperCase();
 return convertedValue;
}

Any help would be greatly appreciated!

Swathi
  • 323
  • 1
  • 4
  • 11
  • 4
    There is no concept of uppercase/lowercase in Japanese, as far as I know. – nhahtdh Sep 26 '12 at 18:43
  • Possibly related - [How do you set strings to uppercase / lowercase in Unicode?](http://stackoverflow.com/questions/297703/how-do-you-set-strings-to-uppercase-lowercase-in-unicode) – Lix Sep 26 '12 at 18:44
  • Are you talking about converting the ョ to ヨ? – Rei Miyasaka Sep 26 '12 at 18:50
  • If what Rei Miyasaka mentioned is what you want to do, then the conversion will change the reading (and meaning) of the original string. – nhahtdh Sep 26 '12 at 18:55
  • 1
    @nhahtdh I think it might make sense if you want to normalize the text for indexing. It's not correct of course, but visually, it could have some merit -- especially for beginners of the language. – Rei Miyasaka Sep 26 '12 at 19:05

3 Answers3

8

There's a list of all the "small" letters (known as "youon") on Wikipedia:

ぁぃぅぇぉっゃゅょゎァィゥェォヵㇰヶㇱㇲッㇳㇴㇵㇶㇷㇷ゚ㇸㇹㇺャュョㇻㇼㇽㇾㇿヮ

You could use a switch statement to convert them to their "big" equivalents, which I'll type out here for your convenience:

あいうえおつやゆよわアイウエオカクケシスツトヌハヒフプヘホムヤユヨラリルレロワ

Note that the consonants aren't necessarily read the same way when they're made "big"; for example, 何ヶ月 is read "なんかげつ(nankagetsu)", not "なんけげつ(nankegetsu)". っ, which indicates a glottal stop on the next syllable, is read as "tsu" when it's made big.

The "big" vowels indicate that they need to be given their own syllable length. (There's a term for this too, but I'm not a linguist -- sorry!)

Rei Miyasaka
  • 7,007
  • 6
  • 42
  • 69
2

I'm a bit ignorant on the names of Japanese characters but I do know that Sugar.js has many methods for manipulating and transforming such characters. It has methods such as zenkaku, hankaku, hiragana, and katakana.

Here's a link to the Sugarjs' String API

richoffrails
  • 1,003
  • 8
  • 11
0

Thanks for the help and guided me to right way

Finally I came up with this solution.

    function convertBigKana(kanaVal){
        var smallKana = Array('ァ','ィ','ゥ','ェ','ォ','ヵ','ヶ','ㇱ','ㇲ','ッ','ㇳ','ㇴ','ㇵ','ㇶ','ㇷ','ㇸ','ㇹ','ㇺ','ャ','ュ','ョ','ㇻ','ㇼ','ㇽ','ㇾ','ㇿ','ヮ');
        var bigKana   = Array('ア','イ','ウ','エ','オ','カ','ケ','シ','ス','ツ','ト','ヌ','ハ','ヒ','フ','ヘ','ホ','ム','ヤ','ユ','ヨ','ラ','リ','ル','レ','ロ','ワ');
        var ckanaVal = '';
        for (var i = 0; i < kanaVal.length; i++){
            //var index = smallKana.indexOf(kanaVal.charAt(i)); //indexOf and stri[i] don't work on ie
            var index = jQuery.inArray(kanaVal.charAt(i), smallKana);
            if (index !== -1) {
                ckanaVal+= bigKana[index];
            }
            else
            {
                ckanaVal+= kanaVal.charAt(i);
            }
        }
        return ckanaVal;
    }
Swathi
  • 323
  • 1
  • 4
  • 11