Added translation of ー
authorPhilipp Reh <sefi@s-e-f-i.de>
Sat, 1 Aug 2009 13:29:41 +0000 (15:29 +0200)
committerPhilipp Reh <sefi@s-e-f-i.de>
Sat, 1 Aug 2009 13:29:41 +0000 (15:29 +0200)
kana2romaji.cpp

index 17c9aea99ba06c3d68ef3167b57356968fe5a75e..646e47c76eed27f507499270f496c5c1bbe83d23 100644 (file)
@@ -331,6 +331,8 @@ void initRomaji() {
     romaji["−"] = "-";
     romaji["―"] = "-";
     romaji[" "] = " ";
+
+    romaji["ー"] = "\3";
 }
 
 void remove_quote_1(
@@ -359,7 +361,7 @@ void kana2romaji(const string& kana, string& rom) {
         if (trans == romaji.end()) {
             rom += ch;
             if (ch.size() > 1)
-                cout << "Don't know how to translate '" << ch << "' in '" << kana << "' to romaji." << endl;
+                cout << "Don't know how to translate '" << ch << "' in '" << kana << "' to romaji.\n";
         }
         else
             rom += trans->second;
@@ -431,4 +433,15 @@ void kana2romaji(const string& kana, string& rom) {
             --pos;
           }
         }
+        else if (rom[pos] == '\3')
+        {
+          if(pos == 0)
+          {
+            cout << "ー is the first letter of a word. Don't know how to translate this.\n";
+            rom.erase(pos);
+            --pos;
+          }
+          else
+            rom[pos] = rom[pos-1];
+        }
 }