google / rust_icu

rust_icu: rust bindings for ICU (International Components for Unicode) library
Apache License 2.0
115 stars 28 forks source link

What is the point of wrapping UText? #6

Open sffc opened 4 years ago

sffc commented 4 years ago

My question here is, where and how do you use the Text that you make? In ICU, a UText is primarily useful for interfacing with APIs like the BreakIterator and regex engine. It doesn't do a whole lot on its own, except maybe providing some more UTF-8 to UTF-16 conversions, but you already have that functionality in rust_icu_ustring.

sffc commented 4 years ago

Also, instead of calling u_strToUTF8, you should consider using the Rust standard library functions like std::str::encode_utf16. the conversion directly in Rust. You would avoid having to go across the FFI boundary when performing the conversion.

filmil commented 4 years ago

Hi @sffc thanks for looking at this code. I don't think Text is used anywhere at the moment. It is mostly an artifact of me trying to understand the FFI binding methods, as I was learning rust at the same time that I was making the wrapper functions.

This is probably one of the first things that were wrapped once I got the low-level sys stuff to build.