コード例 #1
0
ファイル: npc_chat.c プロジェクト: Celso1415/Fusion
int buildin_defpattern (struct script_state *st)
{
	int setid = conv_num (st, & (st->stack->stack_data[st->start + 2]));
	const char *pattern = conv_str (st, & (st->stack->stack_data[st->start + 3]));
	const char *label = conv_str (st, & (st->stack->stack_data[st->start + 4]));
	struct npc_data *nd = (struct npc_data *) map_id2bl (st->oid);
	npc_chat_def_pattern (nd, setid, pattern, label);
	return 0;
}
コード例 #2
0
int main(void)
{
    std::string message("안녕 블라디미르...");

    std::cout << message << std::endl;
    std::string result = conv_str(message, "EUC-KR", "UTF-8");
    std::cout << "|" << result << "|" << std::endl;

    std::cout << conv_str("하늘이 푸릅니다. 창문을 열면 온방에 하나 가득 가슴에 가득...", "EUC-KR", "UTF-8") << std::endl;

    return 0;
}
コード例 #3
0
	inline std::wostream& operator <<(std::wostream& out, pp_as_t<pp::string, char const*> const &v ){
		if( v.m_val ){

			typedef gie::monotonic::fixed_storage<1024*sizeof(wchar_t)+128>	stor_t;
			typedef gie::monotonic::allocator<wchar_t, stor_t> alloc_t;
			typedef std::vector<wchar_t, alloc_t> buffer_t;

			stor_t local_storage;

			buffer_t buffer(  (alloc_t(local_storage))  );

			conv_str(v.m_val, buffer);

			out << buffer.data();
		} else {
			out << STC_P_NULL_LIT;
		}
		return out;
	}
コード例 #4
0
ファイル: autogb.c プロジェクト: suntong/zh-autoconvert
int main(int argc,char*argv[])
{
	int incode,outcode,dist;
	char buff[MAX_BUFFER*3];
	char *pbuf;
	char *ps;
	int need_judge=1;


	int count;

	incode = 0;

	pbuf=&buff[2];

	if( strstr(argv[0],"autogb") != '\0' ){
		outcode=GB_CODE;
	}else if(strstr(argv[0],"autob5") != '\0'){
	
		outcode=BIG5_CODE;
	}
	/* We need one option for encoding at least*/
	if (argc >= 2){ 
	
		/*
		if(argv[1][0] != '-')
			print_help(argv[0]);

		for ( i = 1; i < strlen(argv[1]); i++)
			argv[1][i] = tolower(argv[1][i]);
		
		*/
		/* Get options here. */
		while(1){
			int c;
			int option_index ;
			static struct option long_options[] = 
			{
				{"input", 1, 0, 'i'},
				{"output", 1, 0, 'o'},
				{0, 0, 0, 0},
			};
//			c = getopt_long_only(argc, argv, "io", long_options,
//				&option_index);
			c = getopt_long(argc, argv, "i:o:", long_options,
				&option_index);

			/* No more option, break 'while' loop */
			if ( c == -1 ){
				break; /* While loop */
			}

			switch( c ){
				case 'i':
					need_judge=0;
					if(optarg){
						if((incode=conv_str(optarg))==OTHER_CODE) print_help(argv[0]);
					}else{
						print_help(argv[0]);
					}
					break;

				case 'o':
					if(optarg){
						if((outcode=conv_str(optarg))==OTHER_CODE) print_help(argv[0]);
					}else{
						print_help(argv[0]);
					}
					break;
				case '?':
				default:
					print_help(argv[0]);
					break;
			} /* End switch */

		} /* End while */
	} /* End else if */

	if((count=read(0,pbuf,MAX_BUFFER))< 0){
		fprintf(stderr,"Can't read stdin\n");
	}
	
	/* If incode is set in command line, don't judge. */
	if (need_judge==1)
		incode=j_code(pbuf,count);

	if (incode != outcode){
		hz_setup();
		if((dist=hz_search(incode,outcode,8))==0){
			printf("I couldn't do this conversion\n");
			exit(0);
		}
	}

	do{
		if(incode==outcode){
			write(1,pbuf,count);
		}else{
			ps=hz_convert(pbuf,&count,0);
			write(1,ps,count);
		}
		pbuf=&buff[2];
	}while((count=read(0,pbuf,MAX_BUFFER))>0);
	fflush(0);
}