Example #1
0
/** 
 * Apply charset conversion to a string using libjcode.
 * 
 * @param instr [in] source string
 * @param outstr [out] destination buffer
 * @param maxoutlen [in] allocated length of outstr in byte.
 *
 * @return either of instr or outstr, that holds the result string.
 *
 */
char *
charconv_libjcode(char *instr, char *outstr, int maxoutlen)
{
  switch(convert_to) {
  case SJIS:
    toStringSJIS(instr, outstr, maxoutlen);
    break;
  case EUC:
    toStringEUC(instr, outstr, maxoutlen);
    break;
  case JIS:
    toStringJIS(instr, outstr, maxoutlen);
    break;
  }
  return(outstr);
}
Example #2
0
void main(int ac, char *av[]) {
  char buffer[BUFSIZ];
  int mode=JIS;

  if(ac == 2) {
    if(!strcmp(av[1], "-e")) mode = EUC;
    if(!strcmp(av[1], "-s")) mode =SJIS;
  }

  while(fgets(buffer,BUFSIZ,stdin) != NULL) {
    switch(mode) {
    case EUC:
      printf("%s", toStringEUC(buffer));
      break;
    case SJIS:
      printf("%s", toStringSJIS(buffer));
      break;
    default:
      printf("%s", toStringJIS(buffer));
      break;
    }
  }
  exit(0);
}