Coder Social home page Coder Social logo

mnbase64's Introduction

mac 下的iconv按照网上的例子不成功,一定是哪里调用错了。

为了解决 mac OX 开发下 ansi 和 Unicode 编码的转换问题, 搜到的一个 github

测试可以解决问题。

为什么需要转码,因为base64是针对ansi加解密的,unicode编码必须转换。

跨平台支持,C#版本和VB版本,点击这里

int main(int argc, const char * argv[]) {
    // insert code here...
   
    char* szBuf = "abc中文123";
    myConvert convert;
    int nLen = strlen(szBuf);
    const wchar_t* ppOut;
    convert.ToUtf16(szBuf, nLen, &ppOut);
    
    // 转换结果失败! "abc-\x87123"
    int nwLen = wcslen(ppOut);
    const char* pszBuf;
    convert.WString2String(ppOut, nwLen, &pszBuf);
    
    // 转换正常 abc中文123
    const char* pszUtf8;
    convert.ToUtf8(ppOut, nwLen, &pszUtf8);
    // 释放申请的内存
    Garbage::close();
    
    // base64 加解密测试
    base64Test1();
    // 释放申请的内存
    Garbage::close();
    return 0;
}

mnbase64's People

Contributors

wanttobeno avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.