小编Fre*_*eif的帖子

如何逐行读取unicode(utf-8)/二进制文件

嗨程序员,

我想逐行读取由记事本创建的Unicode(UTF-8)文本文件,我不想在屏幕上显示Unicode字符串,我只想阅读并比较字符串!

此代码逐行读取ANSI文件,并比较字符串

我想要的是

逐行阅读test_ansi.txt

如果line ="b"打印"YES!"

别打印"不!"

read_ansi_line_by_line.c

#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)

c windows encoding utf-8

12
推荐指数
2
解决办法
3万
查看次数

API级Unicode GUI用于Windows/Linux/Mac的C++中的本机应用程序

API级Unicode GUI用于Windows/Linux/Mac OS X的C++中的本机应用程序.


我正在寻找一个简单的Unicode,GUI,Native,应用程序,可以在不需要任何非标准库的情况下运行,使用GNU-GCC(g ++)编译的C++编写.

我不是指一个代码源运行任何地方,而是3(Win/Linux/Mac)代码源!run-without-library(本机应用程序).

*原生申请

应用程序可以在不需要任何非标准库的情况下运行,只需要操作系统C++运行时(如Windows上的MSVCRT).

*Unicode应用程序

从右到左的窗口布局(支持从右到左阅读语言),两个按钮[Message]在消息框中显示UTF-8 stings("اهلابالعالم"),[Exit]到... i想退出!:p

===================================

适用于Windows的解决方案(Windows 7)

编译器: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)

c++ user-interface cross-platform native utf-8

-2
推荐指数
1
解决办法
1689
查看次数

标签 统计

utf-8 ×2

c ×1

c++ ×1

cross-platform ×1

encoding ×1

native ×1

user-interface ×1

windows ×1