lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> On 2 Oct 2016, at 20:00, Xavier Wang <weasley.wx@gmail.com> wrote:
> 
>  hi, I'm the author of luautf8. I think you should use bytes for Lua strings, but not char[]. And java have ability to decode UTF8 byte stream into java string. So maybe this is the way to implement UTF8 module in java. 

Indeed — I can see that would be the correct way. But unfortunately it isn’t as simple: Lua strings are immutable, so it wouldn’t be good enough to have strings represented by byte[] (the contents of the array are mutable in Java), and there is no ByteString or equivalent in the JDK.

So far I went with java.lang.String since it’s ubiquitous in the Java world, (plus Strings may be interned by the JVM), so I thought it would be good for Java interop. But it might be the time to face the issue, and roll my own ByteString for 100% correctness.

> I will look into this to see how to port it to java.

That would be very helpful! Let me know if I can help with anything!

  M.