To enable GBK characters to be displayed on a gui title (using https://github.com/Boscop/web-view), I encoded a utf8 str using GBK encoding into Cow<[u8]>, and tried to convert the result into a GBK &str, but failed. Is there any method available to show the title properly?
str is always utf-8 -- why are you trying to use GBK?
Because the web-view lib doesn't display GBK characters properly in title. In golang, I can use string(GBK encoded bytes) to show it correctly. But in rust, I have no idea.
Wait, so you have GBK input that you've already converted to utf-8 bytes? Then
str::from_utf8 should do the rest of the job. If that doesn't work, can you show the code you are trying?
Thanks for your help. It seemed that the title type should be changed from
impl Into<Vec<u8>> , so that GBK encoded [u8] can be displayed properly in the title. I have submitted an issue.