⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sinocode.c

📁 教育网的bbs代码
💻 C
📖 第 1 页 / 共 2 页
字号:
  int char1, char2;  int outchar1, outchar2;  read_translation_table( translation_files[GB_2312_TO_JIS_EUC]);  while ( (char1 = getc( infilefp )) != EOF )    {      if ( char1 >= 160 && char1 <= 255 )	{	  char2 = getc( infilefp );	  find_gb_big_code( char1, char2, & outchar1, & outchar2 );	  if ( outchar1 == (char) ' ' )	    {	      putc( default_missing_char_codes[JIS_EUC_CODE][FIRST], outfilefp);	      putc( default_missing_char_codes[JIS_EUC_CODE][SECOND], outfilefp);	    }	  else	    {	      putc( (char) outchar1, outfilefp);	      putc( (char) outchar2, outfilefp);	    }	}      else	putc( (char) char1, outfilefp );    }  return;}				/* 4 */void big_5_to_gb_2312( FILE *infilefp, FILE *outfilefp ){  int char1, char2;  int outchar1, outchar2;  read_translation_table( translation_files[BIG_5_TO_GB_2312]);  while ( (char1 = getc( infilefp )) != EOF )    {      if ( char1 >= 160 && char1 <= 255 )	{	  char2 = getc( infilefp );	  find_big_gb_code( char1, char2, & outchar1, &outchar2 );	  if ( outchar1 == (char) ' ' )	    {	      putc( default_missing_char_codes[GB2312_CODE][FIRST], outfilefp);	      putc( default_missing_char_codes[GB2312_CODE][SECOND], outfilefp);	    }	  else	    {	      putc( (char) outchar1, outfilefp);	      putc( (char) outchar2, outfilefp);	    }	}      else	putc( (char) char1, outfilefp );    }    return;}				/* 5 */void big_5_to_ibm_555( FILE *infilefp, FILE *outfilefp ){  int char1, char2;  int outchar1, outchar2;  read_translation_table( translation_files[BIG_5_TO_IBM_555]);  while ( (char1 = getc( infilefp )) != EOF )    {      if ( char1 >= 160 && char1 <= 255 )	{	  char2 = getc( infilefp );	  find_ibm( char1, char2, & outchar1, & outchar2 );	  if ( outchar1 == (char) ' ' )	    {	      putc( default_missing_char_codes[IBM555_CODE][FIRST], outfilefp);	      putc( default_missing_char_codes[IBM555_CODE][SECOND], outfilefp);	    }	  else	    {	      putc( (char) outchar1, outfilefp);	      putc( (char) outchar2, outfilefp);	    }	}      else	putc( (char) char1, outfilefp );    }  return;}				/* 6 */void big_5_to_jis_euc( FILE *infilefp, FILE *outfilefp ){  int char1, char2;  int outchar1, outchar2;  read_translation_table( translation_files[BIG_5_TO_JIS_EUC]);  while ( (char1 = getc( infilefp )) != EOF )    {      if ( char1 >= 160 && char1 <= 255 )	{	  char2 = getc( infilefp );	  find_big_gb_code( char1, char2, & outchar1, & outchar2 );	  if ( outchar1 == (int) ' ' )	    {	      putc( default_missing_char_codes[JIS_EUC_CODE][FIRST], outfilefp);	      putc( default_missing_char_codes[JIS_EUC_CODE][SECOND], outfilefp);	    }	  else	    {	      putc( (char) outchar1, outfilefp);	      putc( (char) outchar2, outfilefp);	    }	}      else	putc( (char) char1, outfilefp );    }  return;}				/* 7 */void jis_euc_to_gb_2312( FILE *infilefp, FILE *outfilefp ){  int char1, char2;  int outchar1, outchar2;  read_translation_table( translation_files[JIS_EUC_TO_GB_2312]);  while ( (char1 = getc( infilefp )) != EOF )    {      if ( char1 >= 160 && char1 <= 255 )	{	  char2 = getc( infilefp );	  find_gb_big_code( char1, char2, & outchar1, & outchar2 );	  if ( outchar1 == (char) ' ' )	    {	      putc( default_missing_char_codes[GB2312_CODE][FIRST], outfilefp);	      putc( default_missing_char_codes[GB2312_CODE][SECOND], outfilefp);	    }	  else	    {	      putc( (char) outchar1, outfilefp);	      putc( (char) outchar2, outfilefp);	    }	}      else	putc( (char) char1, outfilefp );    }  return;}				/* 8 */void jis_euc_to_big_5( FILE *infilefp, FILE *outfilefp ){  int char1, char2;  int outchar1, outchar2;  read_translation_table( translation_files[JIS_EUC_TO_BIG_5]);  while ( (char1 = getc( infilefp )) != EOF )    {      if ( char1 >= 160 && char1 <= 255 )	{	  char2 = getc( infilefp );	  find_gb_big_code( char1, char2, & outchar1, & outchar2 );	  if ( outchar1 == (char) ' ' )	    {	      putc( default_missing_char_codes[BIG5_CODE][FIRST], outfilefp);	      putc( default_missing_char_codes[BIG5_CODE][SECOND], outfilefp);	    }	  else	    {	      putc( (char) outchar1, outfilefp);	      putc( (char) outchar2, outfilefp);	    }	}      else	putc( (char) char1, outfilefp );    }  return;}				/* 9 */void ibm_555_to_big_5( FILE *infilefp, FILE *outfilefp ){  int char1, char2;  int outchar1, outchar2;  return;#ifdef IBM  read_translation_table( translation_files[ibm_555_to_big_5]);    while ( (char1 = getc( infilefp )) != EOF )    {      if ( char1 >= 134 && char <= 255 )	{	  char2 = getc( infilefp );	  find_gb_big_code( char1, char2, & outchar1, & outchar2 );	  if ( outchar1 == (char) ' ' )	    {	      putc( default_missing_char_codes[BIG5_CODE][FIRST], outfilefp);	      putc( default_missing_char_codes[BIG5_CODE][SECOND], outfilefp);	    }	  else	    {	      putc( (char) * outchar1, outfilefp);	      putc( (char) * outchar2, outfilefp);	    }	}      else	putc( (char) char1, outfilefp );    }  return;#endif}				/* 10 */void ibm_555_to_gb_2312( FILE *infilefp, FILE *outfilefp ){  int char1, char2;  int outchar1, outchar2;  read_translation_table( translation_files[IBM_555_TO_GB_2312]);  find_big( char1, char2, & outchar1, & outchar2 );  find_big_gb_code( outchar1, outchar2, &outchar1, &outchar2 );  if ( outchar1 == (char) ' ' )    {      putc( default_missing_char_codes[GB2312_CODE][FIRST], outfilefp);      putc( default_missing_char_codes[GB2312_CODE][SECOND], outfilefp);    }  else    {      putc( (char) outchar1, outfilefp);      putc( (char) outchar2, outfilefp);    }  return;}void main(argc, argv)  int argc;  char **argv;{  FILE *infilefp, *outfilefp;    progname = argv[0];				/* make sure we use the correct */				/* missing chars */  setup_missing_chars_to_use();  				/* this should aways be called with */				/* either one of four arguments. */  if( argc == 2)    {      if( !strcmp(argv[HELPORVERSION], "-version"))	{	  fprintf( stdout, "%s: %s\n", argv[PROGNAME], VERSIONSTRING );	  exit( 0 );	}      else	if( ! strcmp(argv[HELPORVERSION], "-help"))	  {	    print_help();	    exit( 0 );	  }    }  else    if( argc == 5 )      {				/* first check the two files. */	if( ! strcmp( argv[INFILENAME], "-"))	  infilefp = stdin;	else	  if( ! (infilefp = fopen( argv[INFILENAME], "r")))	    {	      fprintf(stderr, "%s: Couldn't open input file: \"%s\"\n",		      argv[PROGNAME], argv[INFILENAME]);	      exit( 1 );	    }	if( ! strcmp( argv[OUTFILENAME], "-"))	  outfilefp = stdout;	else				/* perhaps we should stat here to make */				/* sure that we do not overwrite */				/* something. perham: future */	  if( ! (outfilefp = fopen( argv[OUTFILENAME], "w")))	    {	      fprintf(stderr, "%s: Couldn't open output file: \"%s\"\n",		      argv[PROGNAME], argv[INFILENAME]);	      exit( 1 );	    }				/* then parse the switches and */				/* directly jump to the conversion */	/* GB-2312   -->  BIG-5  */	if((0 == strcmp( argv[INFILECONV], "-gb")) &&	   (0 == strcmp( argv[OUTFILECONV], "-big")))	  {	    gb_2312_to_big_5( infilefp, outfilefp );	    goto out;	  }	/* GB-2312   -->  IBM-555  */	if((0 == strcmp( argv[INFILECONV], "-gb")) &&	   (0 == strcmp( argv[OUTFILECONV], "-ibm")))	  {	    ( infilefp, outfilefp );	    goto out;	  }	/* GB-2312   -->  JIS (EUC)  */	if((0 == strcmp( argv[INFILECONV], "-gb")) &&	   (0 == strcmp( argv[OUTFILECONV], "-jis")))	  {	    gb_2312_to_jis_euc( infilefp, outfilefp );	    goto out;	  }	/* BIG-5     -->  GB-2312  */	if((0 == strcmp( argv[INFILECONV], "-big")) &&	   (0 == strcmp( argv[OUTFILECONV], "-gb")))	  {	    big_5_to_gb_2312( infilefp, outfilefp );	    goto out;	  }	/* BIG-5     -->  IBM-555  */	if((0 == strcmp( argv[INFILECONV], "-big")) &&	   (0 == strcmp( argv[OUTFILECONV], "-ibm")))	  {	    big_5_to_ibm_555( infilefp, outfilefp );	    goto out;	  }	/* BIG-5     -->  JIS (EUC)  */	if((0 == strcmp( argv[INFILECONV], "-big")) &&	   (0 == strcmp( argv[OUTFILECONV], "-jis")))	  {	    big_5_to_jis_euc( infilefp, outfilefp );	    goto out;	  }	/* JIS (EUC) -->  GB-2312  */	if((0 == strcmp( argv[INFILECONV], "-jis")) &&	   (0 == strcmp( argv[OUTFILECONV], "-gb")))	  {	    jis_euc_to_gb_2312( infilefp, outfilefp );	    goto out;	  }	/* JIS (EUC) -->  BIG-5  */	if((0 == strcmp( argv[INFILECONV], "-jis")) &&	   (0 == strcmp( argv[OUTFILECONV], "-big")))	  {	    jis_euc_to_big_5( infilefp, outfilefp );	    goto out;	  }	/* IBM-555   -->  BIG-5  */	if((0 == strcmp( argv[INFILECONV], "-ibm")) &&	   (0 == strcmp( argv[OUTFILECONV], "-big")))	  {	    ibm_555_to_big_5( infilefp, outfilefp );	    goto out;	  }	/* IBM-555   -->  GB-2312  */	if((0 == strcmp( argv[INFILECONV], "-ibm")) &&	   (0 == strcmp( argv[OUTFILECONV], "-gb")))	  {	    ibm_555_to_gb_2312( infilefp, outfilefp );	    goto out;	  }					/* If we arrive here, then we have not */				/* found a coding scheme */	fprintf(stderr, "%s: Unknown coding scheme(s)\n",		argv[PROGNAME]);				/* we do use goto! :-) */      out:;      }				/* four arguments */    else      {	fprintf( stderr, "%s: %s\n", argv[0], "Wrong number of arguments");	exit( 1 );      }				/* Just a plain exit. */  exit( 0 );}				/* main */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -