;-------------------------------------------------- ;convert katakana name into roman syllabes ;unicode version @KANA_TO_ROMAN(ARGS) #FUNCTIONS #DIM LCOUNT #DIMS KANAWORD #DIMS LETTER ;single letter-kana #DIMS ROMAN ;converted word #DIMS SILLAB ;converted syllabe #DIM DOUBLE LOCAL = 0 KANAWORD = %ARGS% LOCAL:2 = STRLENSU(ARGS) ; ;#FUNCTION === functions which return a number ;#FUNCTIONS === functions which return a string ;STRLENS(ARG) ;Measures and returns the length of the string specified in the argument str. ;The length is the number of bytes in SHIFT-JIS. In other words, a full-width character is counted as two characters. ; ;int STRLENSU(str s) ;Measures and returns the length of the string specified in the argument str. ;The length is simply the number of characters. In other words, double-byte characters are counted as one character. ; ;str SUBSTRINGU(str s, int start = 0, int length = -1) ;This is the Unicode version of SUBSTRING. The difference is that double-byte characters are counted as one character. ; ;PRINTL ;PRINTFORML the string to convert is "%KANAWORD%" ;PRINTFORML and it is {LOCAL:2} characters long ROMAN = DOUBLE = 0 IF LOCAL:2 == 0 ROMAN = "no name" ELSE ;create a temp var to store the converted name ROMAN = ;and a variable for the single char to convert ;LETTER = FOR LCOUNT, 0, LOCAL:2 LETTER = %SUBSTRINGU(KANAWORD, LCOUNT, 1)% ;PRINTFORM %LETTER% SILLAB = SELECTCASE LETTER CASE "ア" SILLAB += "A" ; (a) [a" ; CASE "イ" SILLAB += "I" ; (i) [i" ; CASE "ウ" SILLAB += "U" ; (u) [u" ; CASE "エ" SILLAB += "E" ; (e) [e" ; CASE "オ" SILLAB += "O" ; (o) [o" ; CASE "カ" SILLAB += "KA" ; (ka) [ka" ; CASE "キ" SILLAB += "KI" ; (ki) [ki" ; CASE "ク" SILLAB += "KU" ; (ku) [ku" ; CASE "ケ" SILLAB += "KE" ; (ke) [ke" ; CASE "コ" SILLAB += "KO" ; (ko) [ko" ; CASE "サ" SILLAB += "SA" ; (sa) [sa" ; CASE "シ" SILLAB += "SHI" ; (shi) [shi" ; CASE "ス" SILLAB += "SU" ; (su) [su" ; CASE "セ" SILLAB += "SE" ; (se) [se" ; CASE "ソ" SILLAB += "SO" ; (so) [so" ; CASE "タ" SILLAB += "TA" ; (ta) [ta" ; CASE "チ" SILLAB += "CHI" ; (chi) [chi" ; CASE "ツ" SILLAB += "TSU" ; (tsu) [tsu" ; CASE "テ" SILLAB += "TE" ; (te) [te" ; CASE "ト" SILLAB += "TO" ; (to) [to" ; CASE "ナ" SILLAB += "NA" ; (na) [na" ; CASE "ニ" SILLAB += "NI" ; (ni) [ni" ; CASE "ヌ" SILLAB += "NU" ; (nu) [nu" ; CASE "ネ" SILLAB += "NE" ; (ne) [ne" ; CASE "ノ" SILLAB += "NO" ; (no) [no" ; CASE "ハ" SILLAB += "HA" ; (ha) [ha" ; CASE "ヒ" SILLAB += "HI" ; (hi) [hi" ; CASE "フ" SILLAB += "FU" ; (fu) [fu" ; CASE "ヘ" SILLAB += "HE" ; (he) [he" ; CASE "ホ" SILLAB += "HO" ; (ho) [ho" ; CASE "マ" SILLAB += "MA" ; (ma) [ma" ; CASE "ミ" SILLAB += "MI" ; (mi) [mi" ; CASE "ム" SILLAB += "MU" ; (mu) [mu" ; CASE "メ" SILLAB += "ME" ; (me) [me" ; CASE "モ" SILLAB += "MO" ; (mo) [mo" ; CASE "ヤ" SILLAB += "YA" ; (ya) [ya" ; CASE "ユ" SILLAB += "YU" ; (yu) [yu" ; CASE "ヨ" SILLAB += "YO" ; (yo) [yo" ; CASE "ラ" SILLAB += "RA" ; (ra) [ra" ; CASE "リ" SILLAB += "RI" ; (ri) [ri" ; CASE "ル" SILLAB += "RU" ; (ru) [ru" ; CASE "レ" SILLAB += "RE" ; (re) [re" ; CASE "ロ" SILLAB += "RO" ; (ro) [ro" ; CASE "ワ" SILLAB += "WA" ; (wa) [wa" ; CASE "ヲ" SILLAB += "WO" ; (wo) [wo" ; CASE "ン" SILLAB += "N" ; (n) [n" ; ---------------------- CASE "ガ" SILLAB += "GA" CASE "ギ" SILLAB += "GI" CASE "グ" SILLAB += "GU" CASE "ゲ" SILLAB += "GE" CASE "ゴ" SILLAB += "GO" CASE "ザ" SILLAB += "ZA" CASE "ジ" SILLAB += "ZI" CASE "ズ" SILLAB += "ZU" CASE "ゼ" SILLAB += "ZE" CASE "ゾ" SILLAB += "ZO" CASE "ダ" SILLAB += "DA" CASE "ヂ" SILLAB += "DI" CASE "ヅ" SILLAB += "DU" CASE "デ" SILLAB += "DE" CASE "ド" SILLAB += "DO" CASE "バ" SILLAB += "BA" CASE "ビ" SILLAB += "BI" CASE "ブ" SILLAB += "BU" CASE "ベ" SILLAB += "BE" CASE "ボ" SILLAB += "BO" CASE "パ" SILLAB += "PA" CASE "ピ" SILLAB += "PI" CASE "プ" SILLAB += "PU" CASE "ペ" SILLAB += "PE" CASE "ポ" SILLAB += "PO" CASE "ヴ" ;-------------------------------------- SILLAB += "VU" CASE "ァ" SILLAB += "a" CASE "ィ" SILLAB += "i" CASE "ゥ" SILLAB += "u" CASE "ェ" SILLAB += "e" CASE "ォ" SILLAB += "o" CASE "ャ" SILLAB += "ya" CASE "ュ" SILLAB += "yu" CASE "ョ" SILLAB += "yo" CASE "ー" ; special kanas-------------------------------------- ;doubles the former vowel ;get the last letter added in roman, should be a vowel ;PRINTFORM %SUBSTRINGU(ROMAN, STRLENSU(ROMAN)-1, 1)% SILLAB += SUBSTRINGU(ROMAN, STRLENSU(ROMAN)-1, 1) CASE "ッ" ;doubles the following consonant ;the DOUBLE flag will make the double consonant happen in the next cycle, once it scores 1 DOUBLE = 2 ;PRINT -double- SILLAB = CASEELSE SILLAB += LETTER ENDSELECT IF DOUBLE > 0 IF DOUBLE == 1 ;it's time to double the last consonant ;SILLAB = (first letter of SILLAB) + SILLAB SILLAB = %SUBSTRINGU(SILLAB, 0, 1)%%SILLAB% ENDIF DOUBLE -= 1 ENDIF ROMAN += SILLAB ;PRINTFORML - %SILLAB% NEXT ;PRINTL - ENDIF ;PRINTFORML THE CONVERTED STRING IS <<%ROMAN%>> ;RESULTS:4 = ROMAN RETURNF ROMAN ;--------------------------------------------------