File: string.rs

package info (click to toggle)
rust-magnus 0.7.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,468 kB
  • sloc: ruby: 150; sh: 17; makefile: 2
file content (13 lines) | stat: -rw-r--r-- 308 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
use magnus::{prelude::*, Value};

#[test]
fn it_converts_to_utf8_string() {
    let ruby = unsafe { magnus::embed::init() };

    let val: Value = ruby
        .eval(r#""caf\xE9".force_encoding("ISO-8859-1")"#)
        .unwrap();
    let s = String::try_convert(val).unwrap();

    assert_eq!("café", s);
}