Skip to content

UTF_16LE.encode does not encode string to UTF-16 LE correctly? #31

Closed
@itn3000

Description

Environment

rustc --version output:

rustc 1.27.0-nightly (0b72d48f8 2018-04-10)

and my encoding_rs version is 0.7.2.

Steps to reproduce

run the following program

extern crate encoding_rs;

use encoding_rs::UTF_16LE;

fn main() {
    let s = "aa";
    let (bytes, enc, unmappable) = UTF_16LE.encode(s);
    let (dec, enc, unmappable) = UTF_16LE.decode(&bytes);
    for i in dec.chars() {
        println!("{}", i as i32)
    }
    println!("{}", dec);
}

Expected

output following text

97
0
97
0
aa

Actual

output following text(24929 = 0x6161)

24929
慡

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions