wchar_t阅读 [英] wchar_t reading

查看:108
本文介绍了wchar_t阅读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在读取文件的功能上有错误,但是我不知道出了什么问题.当符号超出ASCII表时,将正确读取所有符号.

I have a mistake in the function for reading the file but I don't know what is wrong. all the symbols are read correctly when the symbol is beyond the ASCII table.

while ((c = fgetwc(file)) != WEOF) {
        if (c != L'\n') {
            if (i == buf_length) {
                buf_length += BUF;
                wchar_t *rebuf = realloc(tmp, buf_length * sizeof(wchar_t));
                if (rebuf == NULL) {
                    free(tmp);
                    tmp = NULL;
                    buf_length = 0;
                    return EALLOC;
                } else {
                    tmp = rebuf;
                }
            }
            tmp[i] = (wchar_t)c;
            i++;
        } else {
            list->size++;
            tmp[i] = L'\0';
            insertLast(list, tmp);
            i = 0;
        }

推荐答案

是否已定义_UNICODE?另外,请检查遇到WEOF时是否没有错误(使用ferror和feof),这可能意味着错误.

Is _UNICODE defined? Also, check that you do not get an error (use ferror and feof) when you encounter WEOF as it could mean either.

http://msdn.microsoft. com/en-us/library/c7sskzc1%28v = vs.71%29.aspx

这篇关于wchar_t阅读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆