Created
May 20, 2013 21:59
-
-
Save ispedals/5615924 to your computer and use it in GitHub Desktop.
Converts Aozora Bunko rubi format to Microsoft Word formatted phonetic guide
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub rubier() | |
Dim pattern As String | |
Dim text As String | |
Dim parts() As String | |
Dim kana As String | |
Dim kanji As String | |
'pattern = [U+4E00-U+9FFF]{1,}U+12298?*U+12299 | |
'pattern = \p{InCJK_Unified_Ideographs}{1,}\N{left double angle bracket}?*\N{right double angle bracket} | |
pattern = "[" & ChrW(19968) & "-" & ChrW(40959) & "]{1,}" & ChrW(12298) & "?*" & ChrW(12299) | |
Do While Selection.Find.Execute(FindText:=pattern, MatchWildcards:=True, Replace:=wdReplaceNone, Wrap:=wdFindContinue) = True | |
text = Selection.text | |
parts = Split(text, ChrW(12298)) | |
kanji = parts(0) | |
kana = Replace(parts(1), ChrW(12299), "") | |
Selection.text = kanji | |
Selection.Range.PhoneticGuide text:=kana, Alignment:=wdPhoneticGuideAlignmentOneTwoOne | |
Loop | |
End Sub | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment