zoukankan      html  css  js  c++  java
  • 编码格式(未完待续......)

    1. /u->中文:
        将/u后面的16进制转化成10进制,然后赋值给wchar_t/byte;
    2. 中文->/u:
     
    3. utf-8:
        utf-8 w/o BOM:没有BOM头
        utf-8:有3个字节的BOM头,EFBBBF(utf-16头:FFFE),属于unicode编码格式;
     1 // 判断是否有BOM头,如果有,则去掉BOW头,然后保存。
     2  string strVal;
     3  string strPath = CStringHelper::Unicode2ACSII(CProcHelper::GetCurrentProcessPath());
     4  strPath += "\test_utf8.txt";
     5  ifstream ifs(strPath.c_str(), ios::binary);
     6  if (ifs.is_open())
     7  {
     8    stringstream ss;
     9    ss << ifs.rdbuf();
    10    strVal = ss.str();
    11    ifs.close();
    12 
    13    // 判断是否有头
    14    // BOM头:EFBBBF
    15    bool b = false;
    16    if (0xEF == (byte)strVal.at(0) &&
    17     0xBB == (byte)strVal.at(1) &&
    18     0xBF == (byte)strVal.at(2))
    19    {
    20        b = true;
    21    }
    22  
    23   // 去掉头
    24   strVal = strVal.substr(3, strVal.length() - 3);
    25 
    26   string strPath2 = CStringHelper::Unicode2ACSII(CProcHelper::GetCurrentProcessPath());
    27   strPath2 += "\test_utf8_bk.txt";
    28   ofstream ofs(strPath2, ios::binary);
    29   if (ofs.is_open())
    30   {
    31    ofs << strVal;
    32    ofs.close();
    33   }
    34  }
  • 相关阅读:
    Dom修改元素样式
    URL百分号编码
    accesskey附上一些实例
    dom实例
    dom 创建时间
    关系运算符
    赋值运算符
    js图片随机切换
    js自增图片切换
    transform-origin盒子旋转位置
  • 原文地址:https://www.cnblogs.com/nchxmoon/p/4391722.html
Copyright © 2011-2022 走看看