zoukankan      html  css  js  c++  java
  • 第37月第30天 windows自带记事本导致文本文件(UTF-8编码)开头三个字符乱码问题

    1.windows自带记事本导致文本文件(UTF-8编码)开头三个字符乱码问题

    https://www.cnblogs.com/zhbzz2007/p/4283194.html

        static Byte utf8HeaderBytes[]    = { 0xEF, 0xBB, 0xBF };
        static Byte utf16leHeaderBytes[] = { 0xFF, 0xFE };
        static Byte utf16beHeaderBytes[] = { 0xFE, 0xFF };
        static Byte utf32leHeaderBytes[] = { 0xFF, 0xFE, 0x00, 0x00 };
        static Byte utf32beHeaderBytes[] = { 0x00, 0x00, 0xFE, 0xFF };
        
        NSData *utf8Header    = [NSData dataWithBytes:utf8HeaderBytes length:sizeof(utf8HeaderBytes)];
        NSData *utf16leHeader = [NSData dataWithBytes:utf16leHeaderBytes length:sizeof(utf16leHeaderBytes)];
        NSData *utf16beHeader = [NSData dataWithBytes:utf16beHeaderBytes length:sizeof(utf16beHeaderBytes)];
        NSData *utf32leHeader = [NSData dataWithBytes:utf32leHeaderBytes length:sizeof(utf32leHeaderBytes)];
        NSData *utf32beHeader = [NSData dataWithBytes:utf32beHeaderBytes length:sizeof(utf32beHeaderBytes)];
        
        if ([self doesData:data startWithHeader:utf32leHeader])
        {
            return NSUTF32LittleEndianStringEncoding;
        }
        else if ([self doesData:data startWithHeader:utf32beHeader])
        {
            return NSUTF32BigEndianStringEncoding;
        }
        else if ([self doesData:data startWithHeader:utf8Header])
        {
            return NSUTF8StringEncoding;
        }

    2.

    各操作系统下,文本文件所使用的换行符是不一样的

    UNIX/Linux使用的是0x0A(LF)

    DOS/Windows一直使用的是0x0D0A(CRLF)作为换行符

    如何使用Notepad将LF转换为CRLF

    使用Notepad打开文件点击“编辑”-“档案格式转换”-“转换为windows格式”

      linux命令 sed -i 's/ $//' filename

    http://blog.itpub.net/28282660/viewspace-2638330/

    3.pod libwep

    https://www.jianshu.com/p/eacd3cee51ac

  • 相关阅读:
    MDA模型定义及扩展
    java中 i = i++和 j = i++ 的区别
    nginx+tomcat负载均衡和session复制
    HDU 4010.Query on The Trees 解题报告
    codeforces 165D.Beard Graph 解题报告
    zoj 3209.Treasure Map(DLX精确覆盖)
    hdu 1155 Bungee Jumping
    选择Nginx的理由
    九九乘法表
    K
  • 原文地址:https://www.cnblogs.com/javastart/p/11762989.html
Copyright © 2011-2022 走看看