Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_data returns Chinese string error under windows #94

Closed
gmg137 opened this issue Dec 4, 2018 · 6 comments
Closed

get_data returns Chinese string error under windows #94

gmg137 opened this issue Dec 4, 2018 · 6 comments
Labels

Comments

@gmg137
Copy link

gmg137 commented Dec 4, 2018

The database returns a Chinese string. Running normally under linux, but compiling and running under windows will report the following error:

thread 'main' panicked at 'called Result::unwrap()on anErr value: Utf8Error { valid_up_to: 1, error_len: Some(1) }'
@gmg137 gmg137 changed the title Get_data returns Chinese string error under windows get_data returns Chinese string error under windows Dec 4, 2018
@yuana1
Copy link
Contributor

yuana1 commented Jan 15, 2019

@gmg137 Have you solved it ?

@Koka Koka added the bug label Jan 16, 2019
@yuana1
Copy link
Contributor

yuana1 commented Jan 17, 2019

@Koka When i open win10 utf-8 beta support, it works.
image

I viewed source and find something.
image
can we send a user encoded bytes (like gbk bytes) to sqlserver?
as following

fn prepare_bytes(&mut self, sql_bytes: &[u8]) -> Return<()> {
        match unsafe {
            ffi::SQLPrepare(
                self.handle(),
                sql_bytes.as_ptr(),
                sql_bytes.len() as ffi::SQLINTEGER,
            )
        } {
            ffi::SQL_SUCCESS => Return::Success(()),
            ffi::SQL_SUCCESS_WITH_INFO => Return::SuccessWithInfo(()),
            ffi::SQL_ERROR => Return::Error,
            r => panic!("SQLPrepare returned unexpected result: {:?}", r),
        }
    }

@gmg137
Copy link
Author

gmg137 commented Jan 17, 2019

@yuana1 没解决,我最后是直接把数据库返回数据换成英文了。。。推测是 odbc 的问题,因为我是相同的window sql server 数据库,在linux客户端下没问题,到windows客户端下就有问题了。。。。可能真是你说的那样,需要修改windows客户端的系统编码。

@Koka
Copy link
Owner

Koka commented Jan 17, 2019

can we send a user encoded bytes (like gbk bytes) to sqlserver?

@yuana1 Thanks for your investigation! I have very little experience related to national encoding problems in Rust and have no ability to properly test such cases. It would be great if you could find places where non-utf8 support can be improved and prepare pull request with proposed fixes.

@yuana1
Copy link
Contributor

yuana1 commented Jan 17, 2019

@Koka I will try it!

@Koka
Copy link
Owner

Koka commented Jan 22, 2019

Fix published as 0.10.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants