嗨程序员,
我想逐行读取由记事本创建的Unicode(UTF-8)文本文件,我不想在屏幕上显示Unicode字符串,我只想阅读并比较字符串!
此代码逐行读取ANSI文件,并比较字符串
逐行阅读test_ansi.txt
如果line ="b"打印"YES!"
别打印"不!"
#include <stdio.h>
int main()
{
char *inname = "test_ansi.txt";
FILE *infile;
char line_buffer[BUFSIZ]; /* BUFSIZ is defined if you include stdio.h */
char line_number;
infile = fopen(inname, "r");
if (!infile) {
printf("\nfile '%s' not found\n", inname);
return 0;
}
printf("\n%s\n\n", inname);
line_number = 0;
while (fgets(line_buffer, sizeof(line_buffer), infile)) {
++line_number;
/* note that the newline is in the buffer */
if (strcmp("b\n", line_buffer) == 0 ){
printf("%d: YES!\n", line_number);
}else{
printf("%d: …Run Code Online (Sandbox Code Playgroud) 我正在寻找一个简单的Unicode,GUI,Native,应用程序,可以在不需要任何非标准库的情况下运行,使用GNU-GCC(g ++)编译的C++编写.
我不是指一个代码源运行任何地方,而是3(Win/Linux/Mac)代码源!run-without-library(本机应用程序).
应用程序可以在不需要任何非标准库的情况下运行,只需要操作系统C++运行时(如Windows上的MSVCRT).
从右到左的窗口布局(支持从右到左阅读语言),两个按钮[Message]在消息框中显示UTF-8 stings("اهلابالعالم"),[Exit]到... i想退出!:p
===================================
编译器:MinGW g ++ 4.5.0
命令行:
#include (windows.h)
#include (tchar.h)
#include (string)
typedef std::basic_string<TCHAR> ustring;
LONG StandardExtendedStyle;
TCHAR buffer_1[1024];
TCHAR buffer_2[1024];
static HWND button_1;
static HWND button_2;
inline int ErrMsg(const ustring& s)
{
return MessageBox(0,s.c_str(),_T("ERROR"),MB_OK|MB_ICONEXCLAMATION);
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
case WM_CREATE:
button_1=CreateWindow(L"button",L"UTF-8 Message",WS_CHILD|WS_VISIBLE,10,10,120,25,hwnd,(HMENU)1,NULL,NULL);
button_2=CreateWindow(L"button",L"Exit",WS_CHILD|WS_VISIBLE,10,50,120,25,hwnd,(HMENU)2,NULL,NULL);
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case …Run Code Online (Sandbox Code Playgroud)