Julius 4.2
|
00001 00025 /* 00026 * Copyright (c) 1991-2011 Kawahara Lab., Kyoto University 00027 * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology 00028 * Copyright (c) 2005-2011 Julius project team, Nagoya Institute of Technology 00029 * All rights reserved 00030 */ 00031 00032 #include "app.h" 00033 00034 #ifdef CHARACTER_CONVERSION 00035 #ifdef USE_LIBJCODE 00036 00037 #include "libjcode/jlib.h" 00038 static int convert_to = SJIS; 00039 00049 boolean 00050 charconv_libjcode_setup(char *fromcode, char *tocode, boolean *enable_conv) 00051 { 00052 if (tocode == NULL) { 00053 /* disable conversion */ 00054 *enable_conv = FALSE; 00055 } else { 00056 if (strmatch(tocode, "sjis") 00057 || strmatch(tocode, "sjis-win") 00058 || strmatch(tocode, "shift-jis") 00059 || strmatch(tocode, "shift_jis")) { 00060 convert_to = SJIS; 00061 } else if (strmatch(tocode, "euc-jp") 00062 || strmatch(tocode, "euc") 00063 || strmatch(tocode, "eucjp")) { 00064 convert_to = EUC; 00065 } else if (strmatch(tocode, "jis")) { 00066 convert_to = JIS; 00067 } else { 00068 jlog("Error: charconv_libjcode: character set \"%s\" not supported\n", tocode); 00069 jlog("Error: charconv_libjcode: only \"sjis\", \"euc-jp\" and \"jis\" can be used with libjcode.\n"); 00070 *enable_conv = FALSE; 00071 return FALSE; 00072 } 00073 *enable_conv = TRUE; 00074 } 00075 return TRUE; 00076 } 00077 00088 char * 00089 charconv_libjcode(char *instr, char *outstr, int maxoutlen) 00090 { 00091 switch(convert_to) { 00092 case SJIS: 00093 toStringSJIS(instr, outstr, maxoutlen); 00094 break; 00095 case EUC: 00096 toStringEUC(instr, outstr, maxoutlen); 00097 break; 00098 case JIS: 00099 toStringJIS(instr, outstr, maxoutlen); 00100 break; 00101 } 00102 return(outstr); 00103 } 00104 00105 #endif /* USE_LIBJCODE */ 00106 #endif /* CHARACTER_CONVERSION */