Subject: [ruby-ffi] Re: FFI::StructLayout::CharArray and UTF-8 encoding |
From: Navaneeth KN |
Date: 5/8/12 12:49 AM |
To: ruby-ffi@googlegroups.com |
Hello,
I have a struct which has character arrays which contains UTF8 encoded string. My C library ensures it always works with UTF8 for input and output. I wrapped the C library in ruby using FFI. When reading these values from FFI using FFI::StructLayout::CharArray.read_string gives me a ruby string with encoding ASCII-8BIT. When I try to convert this into UTF-8 using,
str.encode!("UTF-8")