ひらがな/カタカナ変換実装。
1 parent fffddc2 commit 86780bd11046a54753d1527ec883644aa4de930d
@tamra tamra authored on 27 Nov 2004
Showing 6 changed files
View
60
scim-wnn/src/romkan.cpp
{
}
 
 
 
/*!
\fn Romkan::getPos()
*/
int Romkan::getPos()
 
// テーブルを検索して入力する。
unsigned int i = 0;
while(RomkanTable[i] != "") {
if (buf == RomkanTable[i]) {
if (RomkanTable[i + 1] == "") {
if (buf == String(RomkanTable[i])) {
if (String(RomkanTable[i + 1]) == "") {
return(text); // 保留する。
}
WideString w;
iconvert.convert(w,RomkanTable[i + 1]);
iconvert.convert(w,String(RomkanTable[i + 1]));
text = text.substr(0,pos - buf.length()) + w + text.substr(pos);
pos = pos - buf.length() + w.length();
buf.clear();
return(text);
if (getPos() == getTextLength()) return;
text = text.substr(0,pos) + text.substr(pos + 1);
}
 
 
/*!
\fn Romkan::convHiraKata(WideString &t)
*/
void Romkan::convHiraKata(WideString &t)
{
WideString start_c,end_c,conv_c;
iconvert.convert(start_c,String("ぁ"));
iconvert.convert(end_c,String("ん"));
iconvert.convert(conv_c,String("ァ"));
for(unsigned int i = 0;i < t.size();i ++) {
if ((t[i] >= start_c[0]) && (t[i] <= end_c[0]))
t[i] = t[i] - start_c[0] + conv_c[0];
}
return;
}
 
 
/*!
\fn Romkan::convKataHira(WideString &t)
*/
void Romkan::convKataHira(WideString &t)
{
WideString start_c,end_c,conv_c;
iconvert.convert(start_c,String("ァ"));
iconvert.convert(end_c,String("ン"));
iconvert.convert(conv_c,String("ぁ"));
for(unsigned int i = 0;i < t.size();i ++) {
if ((t[i] >= start_c[0]) && (t[i] <= end_c[0]))
t[i] = t[i] - start_c[0] + conv_c[0];
}
return;
 
}
 
 
/*!
\fn Romkan::hiraKata()
*/
void Romkan::hiraKata()
{
convHiraKata(text);
}
 
 
/*!
\fn Romkan::kataHira()
*/
void Romkan::kataHira()
{
convKataHira(text);
}
View
6
scim-wnn/src/romkan.h
#ifndef ROMKAN_H
#define ROMKAN_H
 
#define Uses_SCIM_ICONV
#include <vector>
#include <scim.h>
#include <scim_iconv.h>
 
using namespace std;
using namespace scim;
 
/**
@author TAM(Teppei Tamra)
void reset();
WideString getText(bool hosei = false);
void backspace();
void del();
void convHiraKata(WideString &t);
void convKataHira(WideString &t);
void hiraKata();
void kataHira();
 
protected:
WideString text;
String buf;
View
scim-wnn/src/romkan_table.h
View
scim-wnn/src/scim_wnn_def.h
View
scim-wnn/src/scim_wnn_imengine.cpp
View
scim-wnn/src/scim_wnn_imengine.h