Giter Club home page Giter Club logo

cqpsdk-rust's People

Contributors

doylecnn avatar evshiron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

cqpsdk-rust's Issues

CString Type casting

Currently we declare const char* in C as *const u8 in Rust, however they are CString, who ends with a \0, and if you use CString or CStr to parse the bytes, they will ask for a *const i8 instead of *const u8.

// My current way translating *const i8 into primitive str.
let msgText = std::str::from_utf8(std::ffi::CStr::from_ptr(msg).to_bytes()).unwrap();

Although the primitive str's as_ptr returns a *const u8, and it is working in CQP and WinAPI, they are encoded in UTF-8, while CQP and WinAPI use cp936, which might lead to problems in the future.

So my idea is, replace all *const u8 with *const i8, and use encoding module to solve the encoding conflict.

If you have any idea about this, please don't hesitate to share.

What encoding

I use Sublime Text to compose Rust code, and it's nice when working with UTF-8, however applications in Windows use non-Unicode encoding.

I am thinking about including an encoding module to translate UTF-8 to cp936 when calling APIs, and our code sticks with UTF-8, any ideas?

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.