'MacroName:Korean2Latin 'MacroDescription:Automatically transliterate Korean Hangul characters into Latin characters 'Macro written by: Joel Hahn, Niles Public Library District 'Macro last modified: 23 November 2012 Declare Function DecomposeKorean(sBCR as String) As String Declare Function TransliterateKoreanStandard(sChar As String, sNextChar As String, nPos As Variant) As String Declare Function TransliterateKoreanRevised(sChar As String, sNextChar As String, nPos As Variant) As String Declare Function GetWord(nPos, nStart, nStop) As String Declare Function IsKoreanChar(sNCR) As Integer Global arrChars() Sub Main Dim CS As Object Set CS = CreateObject("Connex.Client") ReDim arrChars(0) ' In the following line, "Y" means "use revised (2009) LC transliteration"; ' "N" means "use standard McCune-Reischauer (1961) transliteration". RevisedTransliteration = "Y" 'nCurRow = CS.CursorRow Select Case CS.ItemType Case 0, 1, 2, 3, 4, 14, 17, 18, 19, 20, 35 'Viewing a MARC record; proceed Case Else MsgBox "Not viewing a MARC record. Exiting..." Exit Sub End Select 'CS.CursorRow = nCurRow bool = CS.GetFieldLineUnicode(CS.CursorRow, sField) NewField = Left(sField, 5) sField = Mid(sField, 6) i = 1 : nHasKorean = 0 Do While i <= Len(sField) - 7 a = Mid(sField, i, 8) If IsKoreanChar(Mid(sField, i, 6)) Then nHasKorean = 1 Exit Do End If i = i + 1 Loop If nHasKorean = 0 Then MsgBox "Field contains no Korean characters. Exiting..." Exit Sub End If 'Change wide spaces to normal spaces Do While InStr(sField, " ") place = InStr(sField, " ") sField = Left(sField, place - 1) & " " & Mid(sField, place + 8) Loop 'Insert comma in names, where feasible 'If Left(NewField, 4) Like "[1678]001" And Len(sField) >= 25 Then ' If IsKoreanChar(Mid(sField, 1, 6)) And Mid(sField, 9, 1) = " " And IsKoreanChar(Mid(sField, 10, 6)) And IsKoreanChar(Mid(sField, 18, 6)) And (Len(sField = 25) Or Mid(sField, 26, 1) Like "[,.]") Then ' If Len(sField) = 25 Then sField = sField & "." ' sField = Left(sField, 8) & ", " & Mid(sField, 10) ' ElseIf IsKoreanChar(Mid(sField, 1, 6)) And IsKoreanChar(Mid(sField, 9, 6)) And Mid(sField, 17, 1) = " " And IsKoreanChar(Mid(sField, 18, 6)) And IsKoreanChar(Mid(sField, 26, 6)) And (Len(sField = 33) Or Mid(sField, 34, 1) Like "[,.]") Then ' If Len(sField) = 33 Then sField = sField & "." ' sField = Left(sField, 16) & ", " & Mid(sField, 18) ' End If 'End If If Left(NewField, 4) Like "[1678]001" And Len(sField) >= 17 Then If IsKoreanChar(Mid(sField, 1, 6)) And Mid(sField, 9, 1) = " " And IsKoreanChar(Mid(sField, 10, 6)) Then 'space between the first two characters (any number of characters in family name) sField = Left(sField, 8) & ", " & Mid(sField, 10) ElseIf IsKoreanChar(Mid(sField, 1, 6)) And IsKoreanChar(Mid(sField, 9, 6)) And Mid(sField, 17, 1) = " " And IsKoreanChar(Mid(sField, 18, 6)) Then 'space between the 2nd & 3rd characters (any number of characters in family name) sField = Left(sField, 16) & ", " & Mid(sField, 18) ElseIf IsKoreanChar(Mid(sField, 1, 6)) And IsKoreanChar(Mid(sField, 9, 6)) And IsKoreanChar(Mid(sField, 17, 6)) And IsKoreanChar(Mid(sField, 25, 6)) Then 'four or more characters in name, with no spaces; if the first two are one of the 2-character family names, treat as such If Left(sField, 16) = "강전" _ Or Left(sField, 16) = "남궁" _ Or Left(sField, 16) = "독고" _ Or Left(sField, 16) = "동방" _ Or Left(sField, 16) = "망절" _ Or Left(sField, 16) = "사공" _ Or Left(sField, 16) = "서문" _ Or Left(sField, 16) = "선우" _ Or Left(sField, 16) = "소봉" _ Or Left(sField, 16) = "어금" _ Or Left(sField, 16) = "장곡" _ Or Left(sField, 16) = "제갈" _ Or Left(sField, 16) = "황보" Then sField = Left(sField, 16) & ", " & Mid(sField, 17) End If ElseIf IsKoreanChar(Mid(sField, 1, 6)) And IsKoreanChar(Mid(sField, 9, 6)) And IsKoreanChar(Mid(sField, 17, 6)) Then 'three characters in name, with no spaces; if the first two are one of the 2-character family names, treat as such If Left(sField, 16) = "강전" _ Or Left(sField, 16) = "남궁" _ Or Left(sField, 16) = "독고" _ Or Left(sField, 16) = "동방" _ Or Left(sField, 16) = "망절" _ Or Left(sField, 16) = "사공" _ Or Left(sField, 16) = "소봉" _ Or Left(sField, 16) = "어금" _ Or Left(sField, 16) = "장곡" _ Or Left(sField, 16) = "제갈" Then 'These are too commonly found either as two-character surname or as one character surname + first character of given name; 'assume one-character surname for these, as that's probably the more common occurrence ' Or Left(sField, 16) = "서문" _ ' Or Left(sField, 16) = "선우" _ ' Or Left(sField, 16) = "황보" _ sField = Left(sField, 16) & ", " & Mid(sField, 17) Else sField = Left(sField, 8) & ", " & Mid(sField, 9) End If ElseIf IsKoreanChar(Mid(sField, 1, 6)) And IsKoreanChar(Mid(sField, 9, 6)) And Mid(sField, 17, 1) Like "[,.]" Then 'two characters in name, with no spaces sField = Left(sField, 8) & ", " & Mid(sField, 9) End If End If 'Break up precomposed Korean characters i = 1 Do While i <= Len(sField) ReDim Preserve arrChars(UBound(arrChars) + 1) If Mid(sField, i, 3) = "&#x" Then place = InStr(i, sField, ";") sBCR = Mid(sField, i, (place - i) + 1) sDecomposed = DecomposeKorean( sBCR ) If InStr(2, sDecomposed, "&#x") Then k = 1 Do While k <= Len(sDecomposed) If k > 1 Then ReDim Preserve arrChars(UBound(arrChars) + 1) place2 = InStr(k, sDecomposed, ";") sSingleBCR = Mid(sDecomposed, k, (place2 - k) + 1) arrChars(UBound(arrChars)) = sSingleBCR k = place2 k = k + 1 Loop Else arrChars(UBound(arrChars)) = sDecomposed End If i = place Else arrChars(UBound(arrChars)) = Mid(sField, i, 1) End If i = i + 1 Loop 'Add any hyphens around embedded numerals i = 1 Do While i <=UBound(arrChars) If Left(arrChars(i), 1) Like "[0-9]" Then If i > 1 Then If InStr(arrChars(i-1), "") Then arrChars(i) = "-" & arrChars(i) End If End If If i < UBound(arrChars) Then If InStr(arrChars(i+1), "") Then arrChars(i) = arrChars(i) & "-" End If End If End If i = i + 1 Loop 'Transliterate any Korean characters i = 1 Do While i <= UBound(arrChars) If InStr(arrChars(i), "&#x") Then sHex = Mid(arrChars(i), 4, Len(arrChars(i)) - 2) nHex = Val("&H" & sHex) Select Case nHex Case &H0 'Character already transliterated; just move along to the next one Case &H1100 To &H1112 'Initial consonant If Left(arrChars(i-1), 4) <> "" Then If RevisedTransliteration = "Y" Then TempChar = TransliterateKoreanRevised(arrChars(i-1), arrChars(i), i) Else TempChar = TransliterateKoreanStandard(arrChars(i-1), arrChars(i), i) End If ElseIf arrChars(i-1) = "�" Then If RevisedTransliteration = "Y" Then TempChar = TransliterateKoreanRevised("�", arrChars(i), i) Else TempChar = TransliterateKoreanStandard("�", arrChars(i), i) End If Else If RevisedTransliteration = "Y" Then TempChar = TransliterateKoreanRevised(" ", arrChars(i), i) Else TempChar = TransliterateKoreanStandard(" ", arrChars(i), i) End If End If ''Insert a hyphen between two-syllable given names in 100, 600, & 700 fields 'If Left(NewField, 4) Like "[1678]001" And i > 3 And TempChar <> "" Then ' If arrChars(i-2) & arrChars(i-1) = ", " Then ' Mid(TempChar, 1, 1) = UCase(Mid(TempChar, 1, 1)) ' End If 'End If 'Capitalize the first character in a field if it is transliterated If TempChar <> "" And (i = 1 or i = 2 or i = 3) And Not (Right(NewField, 2) Like "[0-9]-")Then Mid(TempChar, 1, 1) = UCase(Mid(TempChar, 1, 1)) NewField = NewField + TempChar Case &H1161 To &H1175 'Vowel If RevisedTransliteration = "Y" Then TempChar = TransliterateKoreanRevised(arrChars(i), "�", -1) Else TempChar = TransliterateKoreanStandard(arrChars(i), "�", -1) End If ' This block changes initial "i" to "yi" at the start of a field for 100, 600, 700, and 800 fields If Left(NewField, 4) Like "[1678]001" Then If TempChar = "i" Then If Len(NewField) = 5 Then TempChar = "yi" ' The following block would also change it at the start of any other subfield in those fields ' ElseIf Len(NewField) >= 10 Then ' If Right(NewField, 10) Like "&[#]x01C2;[a-z] " Then ' TempChar = "yi" ' End If End If End If End If 'Insert a hyphen between two-syllable given names in 100, 600, 700, & 800 fields, where the first syllable ends in a vowel If Left(NewField, 4) Like "[1678]001" And i > 2 And UBound(arrChars) >= i+5 Then If arrChars(i-3) & arrChars(i-2) = ", " And arrChars(i+1) = "�" And InStr(arrChars(i+2), "") And arrChars(i+5) Like "[, .]" Then TempChar = TempChar & "-" End If End If NewField = NewField + TempChar Case &H11A8 To &H11C2 'Final consonant If i < UBound(arrChars) Then If InStr(arrChars(i+1), "") Or arrChars(i+1) = "�" Then sNextChar = arrChars(i+1) If RevisedTransliteration = "Y" Then TempChar = TransliterateKoreanRevised(arrChars(i), sNextChar, i) Else TempChar = TransliterateKoreanStandard(arrChars(i), sNextChar, i) End If Else If RevisedTransliteration = "Y" Then TempChar = TransliterateKoreanRevised(arrChars(i), "�", i) Else TempChar = TransliterateKoreanStandard(arrChars(i), "�", i) End If End If Else If RevisedTransliteration = "Y" Then TempChar = TransliterateKoreanRevised(arrChars(i), "�", i) Else TempChar = TransliterateKoreanStandard(arrChars(i), "�", i) End If End If 'Insert a hyphen between two-syllable given names in 100, 600, 700, & 800 fields, where the first syllable ends in a consonant If Left(NewField, 4) Like "[1678]001" And i > 3 And UBound(arrChars) >= i+4 Then If arrChars(i-4) & arrChars(i-3) = ", " And (InStr(arrChars(i+1), "") Or arrChars(i+1) = "�") And arrChars(i+4) Like "[, .]" Then Select Case Len(TempChar) Case 1 TempChar = TempChar & "-" Case 2 If Right(TempChar, 1) = "'" or TempChar = "ng" or TempChar = "ch" or TempChar = "sh" Then TempChar = TempChar & "-" Else TempChar = Left(TempChar, 1) & "-" & Right(TempChar, 1) End If Case 3 If TempChar = "ch'" or TempChar = "tch" Then TempChar = TempChar & "-" ElseIf Left(TempChar, 2) = "ng" Then TempChar = Left(TempChar, 2) & "-" & Right(TempChar, 1) ElseIf Mid(TempChar, 2, 1) = "'" Then TempChar = Left(TempChar, 2) & "-" & Right(TempChar, 1) ElseIf TempChar = "lch" Or Right(TempChar, 1) = "'" Then TempChar = Left(TempChar, 1) & "-" & Right(TempChar, 2) End If Case 4 If Right(TempChar, 3) = "ch'" Then TempChar = Left(TempChar, 1) & "-" & Right(TempChar, 3) End If Case 9 If Right(TempChar, 8) = "ʻ" Then TempChar = Left(TempChar, 1) & "-" & Mid(TempChar, 2) End If Case 10 If TempChar = "chʻ" Then TempChar = TempChar & "-" ElseIf Right(TempChar, 8) = "ʻ" Then TempChar = Left(TempChar, 1) & "-" & Mid(TempChar, 2) ElseIf TempChar = "nʼg" Then TempChar = "nʼ-g" End If Case 11 If Right(Tempchar, 10) = "chʻ" Then TempChar = Left(TempChar, 1) & "-" & Mid(TempChar, 2) End If Case Else 'Do not insert a hyphen End Select End If End If NewField = NewField + TempChar Case Else NewField = NewField & arrChars(i) End Select Else NewField = NewField & arrChars(i) End If i = i + 1 Loop If Mid(NewField, 6, 1) Like "[A-Za-z]" Then Mid(NewField, 6, 1) = UCase(Mid(NewField, 6, 1)) Else i = 6 Do While ((Mid(NewField, i, 1) Like "[!a-z]") And i <= Len(NewField)) i = i + 1 Loop If (Mid(NewField, i-1, 1) <> "#") And (Mid(NewField, i-1, 1) Like "[!A-Z]") And Not (Mid(NewField, i-2, 2) Like "[0-9]-") Then Mid(NewField, i, 1) = UCase(Mid(NewField, i, 1)) End If place3 = 5 Do While InStr(place3, NewField, "ǂ") place3 = InStr(place3, NewField, "ǂ") + 9 Do Until ((Mid(NewField, place3, 1) Like "[A-WY-Za-z]") Or place3 > Len(NewField)) place3 = place3 + 1 Loop If place3 <= Len(NewField) Then If (Mid(NewField, place3, 1) Like "[a-z]") Then If Mid(NewField, place3-1, 1) <> "#" Then Mid(NewField, place3, 1) = UCase(Mid(NewField, place3, 1)) End If End If place3 = place3 + 1 Loop If Left(NewField, 18) = "260 Sŏul " And Mid(NewField, 19, 1) Like "[a-z]" Then Mid(NewField, 19, 1) = UCase(Mid(NewField, 19, 1)) End If If Left(NewField, 3) Like "[1678]00" Or Left(NewField, 3) Like "[1678]10" Then i = 6 Do While i <= Len(NewField) If Mid(NewField, i, 8) = "ǂ" Then Exit Do ElseIf Mid(NewField, i, 2) Like " [a-z]" Then Mid(NewField, i+1, 1) = UCase(Mid(NewField, i+1, 1)) End If i = i + 1 Loop End If bool = CS.AddFieldLine(CS.CursorRow + 1, NewField) CS.CursorRow = CS.CursorRow -1 CS.SendKeys "%ekl", -1 End Sub '############################################################################## Function DecomposeKorean(sBCR As String) As String sHex = Mid(sBCR, 4, Len(sBCR) - 1) nHex = Val("&H" & sHex) Select Case nHex Case &H1100 To &H1112 'initial consonants TempDecompose = "&#x" & Hex(nHex) & ";��" Case &H1161 To &H1175 'middle vowels TempDecompose = "�&#x" & Hex(nHex) & ";�" Case &H11A8 To &H11C2 'final consonants TempDecompose = "��&#x" & Hex(nHex) & ";" Case &HAC00 To &HD7A3 'precomposed combinations nTail = (nHex - &HAC00) Mod 28 nVowel = (((nHex - &HAC00 - nTail) Mod 588) / 28) + 1 nLead = ((nHex - &HAC00) \ 588) + 1 TempDecompose = "&#x" & Hex(nLead + &H10FF) & ";&#x" & Hex(nVowel + &H1160) & ";" If nTail > &H0 Then TempDecompose= TempDecompose & "&#x" & Hex(nTail + &H11A7) & ";" Else TempDecompose = TempDecompose & "�" End If Case Else TempDecompose = sBCR End Select DecomposeKorean = TempDecompose End Function '############################################################################## Function TransliterateKoreanStandard(sChar As String, sNextChar As String, nPos As Variant) As String If sChar <> "�" And Left(sChar, 4) <> "" Then 'Initial consonant with no previous character or which does not change after the previous consonant sHex = Mid(sNextChar, 4, Len(sNextChar) - 2) nHex = Val("&H" & sHex) Select Case nHex 'Consonants Case &H1100 'm-c col 1 TempTranslit = "k" Case &H1101 'm-c col 14 TempTranslit = "kk" Case &H1102 'm-c col 2 TempTranslit = "n" If nPos > 0 And Left(arrChars(nPos - 1), 4) <> "" Then 'Only do when initial Select Case arrChars(nPos + 1) Case "ᅣ", "ᅤ", "ᅧ", "ᅨ", "ᅭ", "ᅲ", "ᅵ" 'Palatalized vowels TempTranslit = "" End Select End If Case &H1103 'm-c col 3 TempTranslit = "t" Case &H1104 'm-c col 15 TempTranslit = "tt" Case &H1105 'm-c col 4 TempTranslit = "n" 'was: "r" If nPos > 0 And Left(arrChars(nPos - 1), 4) <> "" Then 'Only do when initial Select Case arrChars(nPos + 1) Case "ᅣ", "ᅤ", "ᅧ", "ᅨ", "ᅭ", "ᅲ", "ᅵ" 'Palatalized vowels TempTranslit = "" End Select End If Case &H1106 'm-c col 5 TempTranslit = "m" Case &H1107 'm-c col 6 TempTranslit = "p" Case &H1108 'm-c col 16 TempTranslit = "pp" Case &H1109 'm-c col 7 If arrChars(nPos + 1) = "ᅱ" Then TempTranslit = "sh" Else TempTranslit = "s" End If Case &H110A 'm-c col 17 TempTranslit = "ss" Case &H110B 'm-c simplified col 0 or Note 4 TempTranslit = "" Case &H110C 'm-c col 8 TempTranslit = "ch" Case &H110D 'm-c col 18 TempTranslit = "tch" Case &H110E 'm-c col 9 TempTranslit = "chʻ" Case &H110F 'm-c col 10 TempTranslit = "kʻ" Case &H1110 'm-c col 11 TempTranslit = "tʻ" Case &H1111 'm-c col 12 TempTranslit = "pʻ" Case &H1112 'm-c col 13 TempTranslit = "h" End Select ElseIf sChar = "�" And sNextChar <> "�" Then 'Initial consonant with no final consonant in previous character (that is, consonant between two vowels) sHex = Mid(sNextChar, 4, Len(sNextChar) - 1) nHex = Val("&H" & sHex) Select Case nHex 'Consonants Case &H1100 'm-c col 1 TempTranslit = "g" Case &H1101 'm-c col 14 TempTranslit = "kk" Case &H1102 'm-c col 2 TempTranslit = "n" Case &H1103 'm-c col 3 TempTranslit = "d" Case &H1104 'm-c col 15 TempTranslit = "tt" Case &H1105 'm-c col 4 TempTranslit = "r" Case &H1106 'm-c col 5 TempTranslit = "m" Case &H1107 'm-c col 6 TempTranslit = "b" Case &H1108 'm-c col 16 TempTranslit = "pp" Case &H1109 'm-c col 7 If arrChars(nPos + 1) = "ᅱ" Then TempTranslit = "sh" Else TempTranslit = "s" End If Case &H110A 'm-c col 17 TempTranslit = "ss" Case &H110B 'm-c simplified col 0 or Note 4 TempTranslit = "" Case &H110C 'm-c col 8 TempTranslit = "j" Case &H110D 'm-c col 18 TempTranslit = "tch" Case &H110E 'm-c col 9 TempTranslit = "chʻ" Case &H110F 'm-c col 10 TempTranslit = "kʻ" Case &H1110 'm-c col 11 TempTranslit = "tʻ" Case &H1111 'm-c col 12 TempTranslit = "pʻ" Case &H1112 'm-c col 13 TempTranslit = "h" End Select ElseIf sNextChar = "�" Then 'Vowel, or 'Final consonant with no next consonant sHex = Mid(sChar, 4, Len(sChar) - 1) nHex = Val("&H" & sHex) Select Case nHex 'Vowels Case &H1161 TempTranslit = "a" Case &H1162 TempTranslit = "ae" Case &H1163 TempTranslit = "ya" Case &H1164 TempTranslit = "yae" Case &H1165 TempTranslit = "ŏ" Case &H1166 TempTranslit = "e" Case &H1167 TempTranslit = "yŏ" Case &H1168 TempTranslit = "ye" Case &H1169 TempTranslit = "o" Case &H116A TempTranslit = "wa" Case &H116B TempTranslit = "wae" Case &H116C TempTranslit = "oe" Case &H116D TempTranslit = "yo" Case &H116E TempTranslit = "u" Case &H116F TempTranslit = "wŏ" Case &H1170 TempTranslit = "we" Case &H1171 TempTranslit = "wi" Case &H1172 TempTranslit = "yu" Case &H1173 TempTranslit = "ŭ" Case &H1174 TempTranslit = "ŭi" Case &H1175 TempTranslit = "i" 'Consonants Case &H11A8 TempTranslit = "k" 'm-r row 1 Case &H11A9 TempTranslit = "k" 'm-r row 1 Case &H11AA TempTranslit = "k" 'm-r row 1 Case &H11AB TempTranslit = "n" 'm-r row 2 Case &H11AC TempTranslit = "n" 'm-r row 3 Case &H11AD TempTranslit = "n" 'm-r row 4 Case &H11AE TempTranslit = "t" 'm-r row 5 Case &H11AF TempTranslit = "l" 'm-r row 6 Case &H11B0 TempTranslit = "k" 'm-r row 1 Case &H11B1 TempTranslit = "m" 'm-r row 9/10 Case &H11B2 TempTranslit = "l" 'm-r row 6/7 Case &H11B3 TempTranslit = "l" 'm-r row 7 Case &H11B4 TempTranslit = "l" 'm-r row 7 Case &H11B5 TempTranslit = "p" 'm-r row 11 Case &H11B6 TempTranslit = "l" 'm-r row 8 Case &H11B7 TempTranslit = "m" 'm-r row 9 Case &H11B8 TempTranslit = "p" 'm-r row 11 Case &H11B9 TempTranslit = "p" 'm-r row 11 Case &H11BA TempTranslit = "t" 'm-r row 5 Case &H11BB TempTranslit = "t" 'm-r row 5 Case &H11BC TempTranslit = "ng" 'm-r row 12 Case &H11BD TempTranslit = "t" 'm-r row 5 Case &H11BE TempTranslit = "t" 'm-r row 5 Case &H11BF TempTranslit = "k" 'm-r row 1 Case &H11C0 TempTranslit = "t" 'm-r row 5 Case &H11C1 TempTranslit = "p" 'm-r row 11 Case &H11C2 TempTranslit = "t" 'm-r row 15 End Select Else 'Final consonant that must be combined with next initial consonant sHex = Mid(sChar, 4, Len(sChar) - 1) nHex = Val("&H" & sHex) sNextHex = Mid(sNextChar, 4, Len(sNextChar) - 1) nNextHex = Val("&H" & sNextHex) Select Case nHex Case &H11A8, &H11A9, H11AA, &H11B0, &H11BF 'm-r row 1, characters 2-5 TempTranslit = "k" Select Case nNextHex Case &H1102 'm-c col 2 TempTranslit = "ng" Case &H1105 'm-c col 4 TempTranslit = "ngn" arrChars(nPos + 1) = "�" Case &H1106 'm-c col 5 TempTranslit = "ng" Case &H1101 'm-c col 14 TempTranslit = "" End Select Case &H11AB 'm-r row 2 TempTranslit = "n" Select Case nNextHex Case &H1100 'm-c col 1 TempTranslit = "nʼg" arrChars(nPos + 1) = "�" Case &H1103 'm-c col 3 TempTranslit = "nd" arrChars(nPos + 1) = "�" Case &H1105 'm-c col 4 TempTranslit = "ll" arrChars(nPos + 1) = "�" Case &H1107 'm-c col 6 TempTranslit = "nb" arrChars(nPos + 1) = "�" Case &H110C 'm-c col 8 TempTranslit = "nj" arrChars(nPos + 1) = "�" End Select Case &H11AC 'm-r row 3 TempTranslit = "n" Select Case nNextHex Case &H1105 'm-c col 4 TempTranslit = "nn" arrChars(nPos + 1) = "�" Case &H1109 'm-c col 7 TempTranslit = "ns" Case &H1112 'm-c note 8 TempTranslit = "nchʻ" arrChars(nPos + 1) = "�" End Select Case &H11AD 'm-r row 4 TempTranslit = "n" Select Case nNextHex Case &H1100 'm-c col 1 TempTranslit = "nkʻ" arrChars(nPos + 1) = "�" Case &H1103 'm-c col 3 TempTranslit = "ntʻ" arrChars(nPos + 1) = "�" Case &H1105 'm-c col 4 TempTranslit = "nn" arrChars(nPos + 1) = "�" Case &H1107 'm-c col 6 TempTranslit = "pʻ" arrChars(nPos + 1) = "�" Case &H1109 'm-c col 7 TempTranslit = "nss" arrChars(nPos + 1) = "�" Case &H110C 'm-c col 8 TempTranslit = "nchʻ" arrChars(nPos + 1) = "�" End Select Case &H11AE 'm-r row 5, character 1 TempTranslit = "t" Select Case nNextHex Case &H1102 'm-c col 2 TempTranslit = "n" Case &H1105 'm-c col 4 TempTranslit = "nn" arrChars(nPos + 1) = "�" Case &H1106 'm-c col 5 TempTranslit = "n" Case &H1109 'm-c col 7 TempTranslit = "s" Case &H1104 'm-c col 15 TempTranslit = "" Case &H110A 'm-c col 17 TempTranslit = "" Case &H110D 'm-c col 18 TempTranslit = "" Case &H110B 'm-c note 3 Select Case arrChars(nPos + 2) Case "ᅣ", "ᅤ", "ᅧ", "ᅨ", "ᅭ", "ᅲ", "ᅵ" 'Palatalized vowels TempTranslit = "j" End Select End Select Case &H11C0 'm-r row 5, character 5 TempTranslit = "t" Select Case nNextHex Case &H1102 'm-c col 2 TempTranslit = "n" Case &H1105 'm-c col 4 TempTranslit = "nn" arrChars(nPos + 1) = "�" Case &H1106 'm-c col 5 TempTranslit = "n" Case &H1109 'm-c col 7 TempTranslit = "s" Case &H1104 'm-c col 15 TempTranslit = "" Case &H110A 'm-c col 17 TempTranslit = "" Case &H110D 'm-c col 18 TempTranslit = "" Case &H110B 'm-c note 3 Select Case arrChars(nPos + 2) Case "ᅣ", "ᅤ", "ᅧ", "ᅨ", "ᅭ", "ᅲ", "ᅵ" 'Palatalized vowels TempTranslit = "chʻ" End Select End Select Case &H11BA, &H11BB, &H11BD, &H11BE 'm-r row 5, characters 2, 3, 4, & 6 TempTranslit = "t" Select Case nNextHex Case &H1102 'm-c col 2 TempTranslit = "n" Case &H1105 'm-c col 4 TempTranslit = "nn" arrChars(nPos + 1) = "�" Case &H1106 'm-c col 5 TempTranslit = "n" Case &H1109 'm-c col 7 TempTranslit = "s" Case &H1104 'm-c col 15 TempTranslit = "" Case &H110A 'm-c col 17 TempTranslit = "" Case &H110D 'm-c col 18 TempTranslit = "" Case &H110B 'm-c col 0 & rule 3 If nHex = &H11BB Then TempTranslit = "ss" End If End Select Case &H11AF, &H11B2 'm-r row 6, and m-r row 6+7 TempTranslit = "l" Select Case nNextHex Case &H1100 'm-c col 1 TempTranslit = "lg" arrChars(nPos + 1) = "�" Case &H1102 'm-c col 2 TempTranslit = "ll" arrChars(nPos + 1) = "�" Case &H1105 'm-c col 4 TempTranslit = "ll" arrChars(nPos + 1) = "�" Case &H1107 'm-c col 6 TempTranslit = "lb" arrChars(nPos + 1) = "�" Case &H1112 'm-c col 13 TempTranslit = "r" End Select Case &H11B3, &H11B4 'm-r row 7 TempTranslit = "l" Select Case nNextHex Case &H1105 'm-c col 4 TempTranslit = "ll" arrChars(nPos + 1) = "�" Case &H1109 'm-c col 7 TempTranslit = "ls" Case &H1112 'm-c col 13 TempTranslit = "r" End Select Case &H11B6 'm-r row 8 TempTranslit = "l" Select Case nNextHex Case &H1100 'm-c col 1 TempTranslit = "lkʻ" arrChars(nPos + 1) = "�" Case &H1103 'm-c col 3 TempTranslit = "ltʻ" arrChars(nPos + 1) = "�" Case &H1105 'm-c col 4 TempTranslit = "ll" arrChars(nPos + 1) = "�" Case &H1107 'm-c col 6 TempTranslit = "lpʻ" arrChars(nPos + 1) = "�" Case &H1109 'm-c col 7 TempTranslit = "ls" Case &H110C 'm-c col 8 TempTranslit = "lchʻ" arrChars(nPos + 1) = "�" End Select Case &H11B7, &H11B1 'm-r row 9, and m-r row 9+10 TempTranslit = "m" Select Case nNextHex Case &H1100 'm-c col 1 TempTranslit = "mg" arrChars(nPos + 1) = "�" Case &H1103 'm-c col 3 TempTranslit = "md" arrChars(nPos + 1) = "�" Case &H1105 'm-c col 4 TempTranslit = "mn" arrChars(nPos + 1) = "�" Case &H1107 'm-c col 6 TempTranslit = "mb" arrChars(nPos + 1) = "�" Case &H110C 'm-c col 8 TempTranslit = "mj" arrChars(nPos + 1) = "�" End Select Case &H11B5, &H11B8, &H11C1, &H11B9 'm-r row 11 TempTranslit = "p" Select Case nNextHex Case &H1102 'm-c col 2 TempTranslit = "m" Case &H1105 'm-c col 4 TempTranslit = "mn" arrChars(nPos + 1) = "�" Case &H1106 'm-c col 5 TempTranslit = "m" Case &H1108 'm-c col 16 TempTranslit = "" End Select Case &H11BC 'm-r row 12+13 TempTranslit = "ng" Select Case nNextHex Case &H1100 'm-c col 1 TempTranslit = "ngg" arrChars(nPos + 1) = "�" Case &H1103 'm-c col 3 TempTranslit = "ngd" arrChars(nPos + 1) = "�" Case &H1105 'm-c col 4 TempTranslit = "ngn" arrChars(nPos + 1) = "�" Case &H1107 'm-c col 6 TempTranslit = "ngb" arrChars(nPos + 1) = "�" Case &H110C 'm-c col 8 TempTranslit = "ngj" arrChars(nPos + 1) = "�" End Select 'Not represented by a case: m-r row 14 Case &H11C2 'm-r row 15 TempTranslit = "t" Select Case nNextHex Case &H1100 'm-r col 1 TempTranslit = "kʻ" arrChars(nPos + 1) = "�" Case &H1102 'm-r col 2 TempTranslit = "n" Case &H1103 'm-r col 3 TempTranslit = "tʻ" arrChars(nPos + 1) = "�" Case &H1105 'm-r col 4 TempTranslit = "nn" arrChars(nPos + 1) = "�" Case &H1106 'm-r col 5 TempTranslit = "n" Case &H1109 'm-r col 7 TempTranslit = "s" Case &H110C 'm-r col 8 TempTranslit = "chʻ" arrChars(nPos + 1) = "�" Case &H1104 'm-r col 15 TempTranslit = "" Case &H110D 'm-r col 18 TempTranslit = "" End Select Case &H11B0 'not on m-r rows; in m-r note 8 TempTranslit = "lk" Select Case nNextHex Case &H1112 TempTranslit = "lkʻ" arrChars(nPos + 1) = "�" End Select End Select End If TransliterateKoreanStandard = TempTranslit End Function '############################################################################## 'LC Revised Korean Transliteration rules that the macro ignores: ' 'Romanization 'Rule 3 (except for the listed words) 'Rule 4 (except for hyphenating certain patterns of family names) 'Rule 5(a) Exception 1 'Rule 5(a) Exception 2 'Rule 5(b) Exception 1 'Rule 6(d) compound words rule 'Rule 6(e) Exception 'Rule 9(a) (except for 100, 600, 700, and 800 fields) 'Rule 9(b) Exception 1 'Rule 9(b) Exception 2 'Rule 9(b) Exception 3 'Rule 10 Exception 'Rule 11 'Appendix 7, Letter T', Medial rule 3 ' 'Word Division 'All rules (1-14) ' 'Capitalization 'All rules (1-9) ' 'Punctuation 'All rules (1-2) '############################################################################## Function TransliterateKoreanRevised(sChar As String, sNextChar As String, nPos As Variant) As String If sChar <> "�" And Left(sChar, 4) <> "" Then 'Initial consonant with no previous character or which does not change after the previous consonant sHex = Mid(sNextChar, 4, Len(sNextChar) - 2) nHex = Val("&H" & sHex) Select Case nHex 'Consonants Case &H1100 'm-c col 1 TempTranslit = "k" Case &H1101 'm-c col 14 TempTranslit = "kk" Case &H1102 'm-c col 2 TempTranslit = "n" If nPos > 0 And Left(arrChars(nPos - 1), 4) <> "" Then 'Only do when initial Select Case arrChars(nPos + 1) Case "ᅣ", "ᅤ", "ᅧ", "ᅨ", "ᅭ", "ᅲ", "ᅵ" 'Palatalized vowels TempTranslit = "" End Select End If Case &H1103 'm-c col 3 TempTranslit = "t" Case &H1104 'm-c col 15 TempTranslit = "tt" Case &H1105 'm-c col 4 TempTranslit = "n" 'was: "r" If nPos > 0 And Left(arrChars(nPos - 1), 4) <> "" Then 'Only do when initial Select Case arrChars(nPos + 1) Case "ᅣ", "ᅤ", "ᅧ", "ᅨ", "ᅭ", "ᅲ", "ᅵ" 'Palatalized vowels TempTranslit = "" End Select End If 'Special case: ramyo)n If (arrChars(nPos - 1) <> "�" And Left(arrChars(nPos - 1), 4) <> "") and UBound(arrChars) >= nPos + 5 Then sTestWord = arrChars(nPos + 1) & arrChars(nPos + 2) & arrChars(nPos + 3) & arrChars(nPos + 4) & arrChars(nPos + 5) If sTestWord = "ᅡ�면" Then TempTranslit = "r" End If End If Case &H1106 'm-c col 5 TempTranslit = "m" Case &H1107 'm-c col 6 TempTranslit = "p" Case &H1108 'm-c col 16 TempTranslit = "pp" Case &H1109 'm-c col 7 If arrChars(nPos + 1) = "ᅱ" Then TempTranslit = "sh" Else TempTranslit = "s" End If Case &H110A 'm-c col 17 TempTranslit = "ss" Case &H110B 'm-c simplified col 0 or Note 4 TempTranslit = "" Case &H110C 'm-c col 8 TempTranslit = "ch" Case &H110D 'm-c col 18 TempTranslit = "tch" Case &H110E 'm-c col 9 TempTranslit = "ch'" Case &H110F 'm-c col 10 TempTranslit = "k'" Case &H1110 'm-c col 11 TempTranslit = "t'" Case &H1111 'm-c col 12 TempTranslit = "p'" Case &H1112 'm-c col 13 TempTranslit = "h" End Select ElseIf sChar = "�" And sNextChar <> "�" Then 'Initial consonant with no final consonant in previous character (that is, consonant between two vowels) sHex = Mid(sNextChar, 4, Len(sNextChar) - 1) nHex = Val("&H" & sHex) Select Case nHex 'Consonants Case &H1100 'm-c col 1 TempTranslit = "g" Case &H1101 'm-c col 14 TempTranslit = "kk" Case &H1102 'm-c col 2 TempTranslit = "n" Case &H1103 'm-c col 3 TempTranslit = "d" Case &H1104 'm-c col 15 TempTranslit = "tt" Case &H1105 'm-c col 4 TempTranslit = "r" Case &H1106 'm-c col 5 TempTranslit = "m" Case &H1107 'm-c col 6 TempTranslit = "b" Case &H1108 'm-c col 16 TempTranslit = "pp" Case &H1109 'm-c col 7 If arrChars(nPos + 1) = "ᅱ" Then TempTranslit = "sh" Else TempTranslit = "s" End If Case &H110A 'm-c col 17 TempTranslit = "ss" Case &H110B 'm-c simplified col 0 or Note 4 TempTranslit = "" Case &H110C 'm-c col 8 TempTranslit = "j" Case &H110D 'm-c col 18 TempTranslit = "tch" Case &H110E 'm-c col 9 TempTranslit = "ch'" Case &H110F 'm-c col 10 TempTranslit = "k'" Case &H1110 'm-c col 11 TempTranslit = "t'" Case &H1111 'm-c col 12 TempTranslit = "p'" Case &H1112 'm-c col 13 TempTranslit = "h" End Select ElseIf sNextChar = "�" Then 'Vowel or Final consonant with no next consonant sHex = Mid(sChar, 4, Len(sChar) - 1) nHex = Val("&H" & sHex) Select Case nHex 'Vowels Case &H1161 TempTranslit = "a" Case &H1162 TempTranslit = "ae" Case &H1163 TempTranslit = "ya" Case &H1164 TempTranslit = "yae" Case &H1165 TempTranslit = "ŏ" Case &H1166 TempTranslit = "e" Case &H1167 TempTranslit = "yŏ" Case &H1168 TempTranslit = "ye" Case &H1169 TempTranslit = "o" Case &H116A TempTranslit = "wa" Case &H116B TempTranslit = "wae" Case &H116C TempTranslit = "oe" Case &H116D TempTranslit = "yo" Case &H116E TempTranslit = "u" Case &H116F TempTranslit = "wŏ" Case &H1170 TempTranslit = "we" Case &H1171 TempTranslit = "wi" Case &H1172 TempTranslit = "yu" Case &H1173 TempTranslit = "ŭ" Case &H1174 TempTranslit = "ŭi" Case &H1175 TempTranslit = "i" 'Consonants Case &H11A8 TempTranslit = "k" 'm-r row 1 Case &H11A9 TempTranslit = "k" 'm-r row 1 Case &H11AA TempTranslit = "k" 'm-r row 1 Case &H11AB TempTranslit = "n" 'm-r row 2 Case &H11AC TempTranslit = "n" 'm-r row 3 Case &H11AD TempTranslit = "n" 'm-r row 4 Case &H11AE TempTranslit = "t" 'm-r row 5 Case &H11AF TempTranslit = "l" 'm-r row 6 Case &H11B0 TempTranslit = "k" 'm-r row 1 Case &H11B1 TempTranslit = "m" 'm-r row 9/10 Case &H11B2 TempTranslit = "l" 'm-r row 6/7 Case &H11B3 TempTranslit = "l" 'm-r row 7 Case &H11B4 TempTranslit = "l" 'm-r row 7 Case &H11B5 TempTranslit = "p" 'm-r row 11 Case &H11B6 TempTranslit = "l" 'm-r row 8 Case &H11B7 TempTranslit = "m" 'm-r row 9 Case &H11B8 TempTranslit = "p" 'm-r row 11 Case &H11B9 TempTranslit = "p" 'm-4 row 11 Case &H11BA TempTranslit = "t" 'm-r row 5 Case &H11BB TempTranslit = "t" 'm-r row 5 Case &H11BC TempTranslit = "ng" 'm-r row 12 Case &H11BD TempTranslit = "t" 'm-r row 5 Case &H11BE TempTranslit = "t" 'm-r row 5 Case &H11BF TempTranslit = "k" 'm-r row 1 Case &H11C0 TempTranslit = "t" 'm-r row 5 Case &H11C1 TempTranslit = "p" 'm-r row 11 Case &H11C2 TempTranslit = "t" 'm-r row 15 End Select Else 'Final consonant that must be combined with next initial consonant sHex = Mid(sChar, 4, Len(sChar) - 1) nHex = Val("&H" & sHex) sNextHex = Mid(sNextChar, 4, Len(sNextChar) - 1) nNextHex = Val("&H" & sNextHex) Select Case nHex Case &H11A8 'm-r row 1, character 1 TempTranslit = "k" Select Case nNextHex Case &H1102 'm-c col 2 TempTranslit = "ng" Case &H1105 'm-c col 4 TempTranslit = "ngn" arrChars(nPos + 1) = "�" Case &H1106 'm-c col 5 TempTranslit = "ng" Case &H1101 'm-c col 14 TempTranslit = "" Case &H110B 'm-c col 0 TempTranslit = "g" End Select Case &H11BF 'm-r row 1, character 2 TempTranslit = "k'" '*** verify with LC that this is k' instead of just k as it used to be Select Case nNextHex Case &H1105 'm-c col 4 TempTranslit = "k'n" arrChars(nPos + 1) = "�" Case &H1101 'm-c col 14 TempTranslit = "k'" '*** results in "k'kk"; verify with LC End Select Case &H11A9, &H11AA 'm-r row 1, characters 3-4 TempTranslit = "k" Select Case nNextHex Case &H1105 'm-c col 4 TempTranslit = "kn" arrChars(nPos + 1) = "�" Case &H1101 'm-c col 14 TempTranslit = "" '*** otherwise would be "kkk"; verity with LC Case &H110B 'm-c col 0 Select Case nHex Case &H11A9 'm-r row 1, character 3 TempTranslit = "kk" Case &H11AA 'm-r row 1, character 4 TempTranslit = "" End Select End Select Case &H11B0 'm-4 row 1, character 5; m-r note 8 TempTranslit = "k" Select Case nNextHex Case &H1100 'm-c col 1 TempTranslit = "l" Case &H1102 'm-c col 2 TempTranslit = "ng" Case &H1105 'm-c col 4 TempTranslit = "kn" arrChars(nPos + 1) = "�" Case &H1112 'm-c col 13 TempTranslit = "lk'" arrChars(nPos + 1) = "�" Case &H1101 'm-c col 14 TempTranslit = "" '*** otherwise would be "kkk"; verity with LC Case &H110B 'm-c col 0 TempTranslit = "lg" End Select Case &H11AB 'm-r row 2 TempTranslit = "n" Select Case nNextHex Case &H1100 'm-c col 1 TempTranslit = "n'g" arrChars(nPos + 1) = "�" Case &H1103 'm-c col 3 TempTranslit = "nd" arrChars(nPos + 1) = "�" Case &H1105 'm-c col 4 TempTranslit = "ll" If (arrChars(nPos + 2) = "ᅧ" Or arrChars(nPos + 2) = "ᅲ") And arrChars(nPos + 3) = "ᆯ" Then TempTranslit = "n" arrChars(nPos + 1) = "�" End If arrChars(nPos + 1) = "�" Case &H1107 'm-c col 6 TempTranslit = "nb" 'Special cases: munpo)p, ho)npo)p If GetWord(nPos, -2, 3) = "문법" or GetWord(nPos, -2, 3) = "헌법" Then TempTranslit = "np" End If arrChars(nPos + 1) = "�" Case &H110C 'm-c col 8 TempTranslit = "nj" arrChars(nPos + 1) = "�" End Select Case &H11AC 'm-r row 3 TempTranslit = "n" Select Case nNextHex Case &H1105 'm-c col 4 TempTranslit = "nn" arrChars(nPos + 1) = "�" Case &H1112 'm-c note 8 (re: col 13) TempTranslit = "nch'" arrChars(nPos + 1) = "�" Case &H110B 'm-c col 0 TempTranslit = "nj" End Select Case &H11AD 'm-r row 4 TempTranslit = "n" Select Case nNextHex Case &H1100 'm-c col 1 TempTranslit = "nk'" arrChars(nPos + 1) = "�" Case &H1103 'm-c col 3 TempTranslit = "nt'" arrChars(nPos + 1) = "�" Case &H1105 'm-c col 4 TempTranslit = "nn" arrChars(nPos + 1) = "�" Case &H110C 'm-c col 8 TempTranslit = "nch'" arrChars(nPos + 1) = "�" End Select Case &H11AE 'm-r row 5, character 1 TempTranslit = "t" Select Case nNextHex Case &H1102 'm-c col 2 TempTranslit = "n" Case &H1105 'm-c col 4 TempTranslit = "tn" arrChars(nPos + 1) = "�" Case &H1112 'm-c col 13 TempTranslit = "ch'" arrChars(nPos + 1) = "�" Case &H1104 'm-c col 15 TempTranslit = "" Case &H110B 'm-c note 3 TempTranslit = "d" Select Case arrChars(nPos + 2) Case "ᅣ", "ᅤ", "ᅧ", "ᅨ", "ᅭ", "ᅲ", "ᅵ" 'Palatalized vowels TempTranslit = "j" '*** Verify with LC End Select End Select Case &H11BA, &H11BE 'm-r row 5, characters 2 & 4 TempTranslit = "t" Select Case nNextHex Case &H1102 'm-c col 2 TempTranslit = "n" Case &H1105 'm-c col 4 TempTranslit = "tn" arrChars(nPos + 1) = "�" Case &H1106 'm-c col 5 TempTranslit = "n" Case &H1104 'm-c col 15 TempTranslit = "" Case &H110B 'm-c col 0 Select Case nHex Case &H11BA 'm-r row 5, character 2 TempTranslit = "s" If arrChars(nPos + 2) = "ᅱ" Then TempTranslit = "sh" End If Case &H11BE 'm-r row 5, character 3 TempTranslit = "j" End Select End Select Case &H11BD 'm-r row 5, character 3 TempTranslit = "t" Select Case nNextHex Case &H1102 'm-c col 2 TempTranslit = "n" Case &H1105 'm-c col 4 TempTranslit = "tn" arrChars(nPos + 1) = "�" Case &H1106 'm-c col 5 TempTranslit = "n" Case &H1112 'm-c col 13 TempTranslit = "ch'" arrChars(nPos + 1) = "�" Case &H1104 'm-c col 15 TempTranslit = "" Case &H110B 'm-c col 0 TempTranslit = "j" End Select Case &H11C0 'm-r row 5, character 5 TempTranslit = "t" Select Case nNextHex Case &H1102 'm-c col 2 TempTranslit = "n" Case &H1105 'm-c col 4 TempTranslit = "tn" arrChars(nPos + 1) = "�" Case &H1106 'm-c col 5 TempTranslit = "n" Case &H1104 'm-c col 15 TempTranslit = "" Case &H110B 'm-c note 3 TempTranslit = "t'" End Select Case &H11BB 'm-r row 5, character 6 TempTranslit = "t" Select Case nNextHex Case &H1102 'm-c col 2 TempTranslit = "n" Case &H1105 'm-c col 4 TempTranslit = "tn" arrChars(nPos + 1) = "�" Case &H1104 'm-c col 15 TempTranslit = "" Case &H110B 'm-c col 0 TempTranslit = "ss" End Select Case &H11AF 'm-r row 6 TempTranslit = "l" Select Case nNextHex Case &H1100 'm-c col 1 TempTranslit = "lg" arrChars(nPos + 1) = "�" Case &H1102 'm-c col 2 TempTranslit = "ll" arrChars(nPos + 1) = "�" Case &H1103 'm-c col 3 If nPos > 3 And UBound(arrChars) >= nPos + 3 Then 'Special case: So)uldae If GetWord(nPos, -5, 3) = "서�울대�" Then TempTranslit = "ld" arrChars(nPos + 1) = "�" End If End If If nPos > 2 And UBound(arrChars) >= nPos + 6 Then 'Special case: Wo)ldu)ko)p If GetWord(nPos, -2, 6) = "월드�컵" Then TempTranslit = "ld" arrChars(nPos + 1) = "�" End If End If Case &H1105 'm-c col 4 TempTranslit = "ll" arrChars(nPos + 1) = "�" Case &H1107 'm-c col 6 TempTranslit = "lb" arrChars(nPos + 1) = "�" Case &H110C 'm-c col 8 If nPos > 2 And UBound(arrChars) >= nPos + 6 Then 'Special case: kiljabi If GetWord(nPos, -2, 6) = "길잡이�" Then TempTranslit = "lj" arrChars(nPos + 1) = "�" End If End If If nPos > 3 And UBound(arrChars) >= nPos + 3 Then 'Special case: malgaljok If GetWord(nPos, -5, 3) = "말�ᅡᆯ족" Then TempTranslit = "lj" arrChars(nPos + 1) = "�" End If End If Case &H1112 'm-c col 13 TempTranslit = "r" Case &H110B 'm-c col 0 TempTranslit = "r" End Select Case &H11B2 'm-r row 6+7 TempTranslit = "l" Select Case nNextHex Case &H1102 'm-c col 2 If (arrChars(nPos - 1) = "ᅡ" And arrChars(nPos - 2) = "ᄇ") Then TempTranslit = "m" End If Case &H1105 'm-c col 4 TempTranslit = "ln" arrChars(nPos + 1) = "�" Case &H1112 'm-c col 13 TempTranslit = "lp'" arrChars(nPos + 1) = "�" Case &H110B 'm-c col 0 TempTranslit = "lb" End Select If (arrChars(nPos - 1) = "ᅡ" And arrChars(nPos - 2) = "ᄇ") Then TempTranslit = "p" Select Case nNextHex Case &H1102 'm-c col 2 If (arrChars(nPos - 1) = "ᅡ" And arrChars(nPos - 2) = "ᄇ") Then TempTranslit = "m" End If End Select End If '*** The following bit is only true for three words (LC Revised rule 8(b), Exception 2) If (arrChars(nPos - 3) = " " And arrChars(nPos - 2) = "ᄂ" And arrChars(nPos - 1) = "ᅥ") Then If nPos > 2 And UBound(arrChars) >= nPos + 9 Then 'Special case: no)pchukada If GetWord(nPos, 1, 9) = "죽하�다�" Then TempTranslit = "p" 'Special case: no)ptunggu)lda ElseIf GetWord(nPos, 1, 9) = "둥글다�" Then TempTranslit = "p" End If ElseIf nPos > 2 And UBound(arrChars) >= nPos + 3 Then 'Special case: no)pcho)k If GetWord(nPos, 1, 3) = "적" Then TempTranslit = "p" End If End If End If Case &H11B3, &H11B4 'm-r row 7 TempTranslit = "l" Select Case nNextHex Case &H1105 'm-c col 4 TempTranslit = "ln" arrChars(nPos + 1) = "�" Case &H110B 'm-c col 0 Select Case nHex Case &H11B3 'm-r row 7, character 3 Temptranslit = "" Case &H11B4 'm-r row 7, character 4 TempTranslit = "lt'" End Select End Select Case &H11B6 'm-r row 8 TempTranslit = "l" Select Case nNextHex Case &H1100 'm-c col 1 TempTranslit = "lk'" arrChars(nPos + 1) = "�" Case &H1102 'm-c col 2 TempTranslit = "ll" arrChars(nPos + 1) = "�" Case &H1103 'm-c col 3 TempTranslit = "nt'" arrChars(nPos + 1) = "�" Case &H1105 'm-c col 4 TempTranslit = "ll" arrChars(nPos + 1) = "�" Case &H1107 'm-c col 6 TempTranslit = "lp'" arrChars(nPos + 1) = "�" Case &H110C 'm-c col 8 TempTranslit = "lch'" If nPos > 2 and UBound(arrChars) >= nPos + 3 Then 'Special case: silchu)ng If GetWord(nPos, -2, 3) = "싫증" Then TempTranslit = "lch" End If End If arrChars(nPos + 1) = "�" Case &H110B 'm-c col 0 TempTranslit = "r" End Select Case &H11B7 'm-r row 9 TempTranslit = "m" Select Case nNextHex Case &H1100 'm-c col 1 TempTranslit = "mg" arrChars(nPos + 1) = "�" Case &H1103 'm-c col 3 TempTranslit = "md" arrChars(nPos + 1) = "�" Case &H1105 'm-c col 4 TempTranslit = "mn" arrChars(nPos + 1) = "�" Case &H1107 'm-c col 6 TempTranslit = "mb" arrChars(nPos + 1) = "�" Case &H110C 'm-c col 8 TempTranslit = "mj" arrChars(nPos + 1) = "�" End Select Case &H11B1 'm-r row 9+10 TempTranslit = "m" Select Case nNextHex Case &H1105 'm-c col 4 TempTranslit = "mn" arrChars(nPos + 1) = "�" Case &H110B 'm-c col 0 TempTranslit = "lm" End Select Case &H11B8 'm-r row 11, character 1 TempTranslit = "p" Select Case nNextHex Case &H1102 'm-c col 2 TempTranslit = "m" Case &H1105 'm-c col 4 TempTranslit = "mn" arrChars(nPos + 1) = "�" Case &H1106 'm-c col 5 TempTranslit = "m" Case &H1108 'm-c col 16 TempTranslit = "" Case &H110B 'm-c col 0 TempTranslit = "b" End Select Case &H11C1, &H11B5 'm-r row 11, characters 2-3 TempTranslit = "p" Select Case nNextHex Case &H1102 'm-c col 2 TempTranslit = "m" Case &H1105 'm-c col 4 TempTranslit = "pn" arrChars(nPos + 1) = "�" Case &H1108 'm-c col 16 TempTranslit = "" Case &H110B 'm-c col 0 If nHex = &H11B5 Then TempTranslit = "lp'" End If End Select Case &H11B9 'm-r row 11, character 4 TempTranslit = "p" Select Case nNextHex Case &H1105 'm-c col 4 TempTranslit = "pn" arrChars(nPos + 1) = "�" Case &H1108 'm-c col 16 TempTranslit = "" Case &H110B 'm-c col 0 TempTranslit = "ps" If nPos > 2 And UBound(arrChars) > nPos + 6 Then 'Special case: kabo)ch'i If GetWord(nPos, -2, 6) = "값어�치�" Then TempTranslit = "b" End If End If End Select Case &H11BC 'm-r row 12+13 TempTranslit = "ng" Select Case nNextHex Case &H1100 'm-c col 1 TempTranslit = "ngg" 'Special case: p'yo)ngka If GetWord(nPos, -2, 3) = "평가�" Then 'arrChars(nPos + 2) = "ᅡ" And arrChars(nPos + 3) = "�" And arrChars(nPos - 2) = "ᄑ" And arrChars(nPos - 1) = "ᅧ" Then TempTranslit = "ngk" End If arrChars(nPos + 1) = "�" Case &H1103 'm-c col 3 TempTranslit = "ngd" arrChars(nPos + 1) = "�" Case &H1105 'm-c col 4 TempTranslit = "ngn" arrChars(nPos + 1) = "�" Case &H1107 'm-c col 6 TempTranslit = "ngb" arrChars(nPos + 1) = "�" Case &H110C 'm-c col 8 TempTranslit = "ngj" arrChars(nPos + 1) = "�" End Select 'Not represented by a case: m-r row 14 Case &H11C2 'm-r row 15 TempTranslit = "t" Select Case nNextHex Case &H1100 'm-r col 1 TempTranslit = "k'" arrChars(nPos + 1) = "�" Case &H1102 'm-r col 2 TempTranslit = "n" Case &H1103 'm-r col 3 TempTranslit = "t'" arrChars(nPos + 1) = "�" Case &H1105 'm-r col 4 TempTranslit = "nn" arrChars(nPos + 1) = "�" Case &H1106 'm-r col 5 TempTranslit = "n" Case &H1107 'm-c col 6 TempTranslit = "n" Case &H1109 'm-r col 7 TempTranslit = "s" Case &H110C 'm-r col 8 TempTranslit = "ch'" arrChars(nPos + 1) = "�" Case &H1104 'm-r col 15 TempTranslit = "" Case &H110D 'm-r col 18 TempTranslit = "" Case &H110B 'm-c col 0 TempTranslit = "" End Select End Select End If TransliterateKoreanRevised = TempTranslit End Function '############################################################################## Function GetWord(nPos, nStart, nStop) As String sTempWord = "" i = nStart Do While i <= nStop sTempWord = sTempWord & arrChars(nPos + i) i = i + 1 Loop GetWord = sTempWord End Function '############################################################################## Function IsKoreanChar(sNCR) As Integer If Len(sNCR) = 6 And ((Mid(sNCR, 1, 6) Like "&[#]x11[0-9ABC]") Or (Mid(sNCR, 1, 5) Like "&[#]xA[C-F]") Or (Mid(sNCR, 1, 4) Like "&[#]xB") Or (Mid(sNCR, 1, 4) Like "&[#]xC") Or (Mid(sNCR, 1, 6) Like "&[#]xD[0-7][0-9A]")) Then IsKoreanChar = 1 Else IsKoreanChar = 0 End If End Function