日语字符:使用jquery将小写转换为大写

时间:2022-09-06 22:43:04

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

我尝试使用toUppercase()方法将日文字符转换为大写,但它返回相同的字符串而不进行外转换。

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

使用jquery或javascript还有其他方法来实现这一点吗?

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

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

Any help would be greatly appreciated!

如有任何帮助,我们将不胜感激!

3 个解决方案

#1


6  

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

*上列出了所有的“小”字母(被称为“youon”):

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

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

您可以使用switch语句将它们转换为“big”等价物,我将在这里输入,以便您方便:

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

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.

注意,当辅音被做成“大”的时候,它们的读法不一定相同;例如,何ヶ月读”なんかげつ(nankagetsu)”,而不是“なんけげつ(nankegetsu)”。っ,这表明声门的停在第二个音节,读为“台联党”的时候大。

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

“大”元音表示需要给它们自己的音节长度。(这也有一个术语,但我不是语言学家——对不起!)

#2


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.

我对日本汉字的名字有点不知道,但我知道那个糖。js有许多处理和转换这些字符的方法。它有zenkaku、hankaku、hiragana和katakana等方法。

Here's a link to the Sugarjs' String API

下面是Sugarjs的字符串API的链接

#3


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

#1


6  

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

*上列出了所有的“小”字母(被称为“youon”):

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

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

您可以使用switch语句将它们转换为“big”等价物,我将在这里输入,以便您方便:

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

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.

注意,当辅音被做成“大”的时候,它们的读法不一定相同;例如,何ヶ月读”なんかげつ(nankagetsu)”,而不是“なんけげつ(nankegetsu)”。っ,这表明声门的停在第二个音节,读为“台联党”的时候大。

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

“大”元音表示需要给它们自己的音节长度。(这也有一个术语,但我不是语言学家——对不起!)

#2


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.

我对日本汉字的名字有点不知道,但我知道那个糖。js有许多处理和转换这些字符的方法。它有zenkaku、hankaku、hiragana和katakana等方法。

Here's a link to the Sugarjs' String API

下面是Sugarjs的字符串API的链接

#3


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