You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Harbs <ha...@gmail.com> on 2016/07/01 11:39:13 UTC

Encode and Decode UTF8

We have a need to read and write UTF8 strings to “ByteArrays” in FlexJS. FlexJS already has a BinaryData class which can serve as a stand-in for ByteArray, but it’s missing reading and writing UTF8. I’d like to add these methods.

UTF8 gets a bit complicated when dealing with 2,3 and 4 byte characters. There’s a JS library which solves this problem already on GotHub[1]. The code was placed into public domain[2].

Is there any problem just adopting the part of the code relevant to UTF8? Do we need to add a notice?

Harbs

[1]https://github.com/inexorabletash/text-encoding/blob/master/lib/encoding.js
[2]https://github.com/inexorabletash/text-encoding/blob/master/LICENSE.md

Re: Encode and Decode UTF8

Posted by Justin Mclean <ju...@classsoftware.com>.
HI,

> Thanks for the links. I looks like the unlicensed license is a derivative of the CC0 license, so if I’m reading it right, it’s binding and about as permissive as you can get.

It looks that way but it best to get it added to the list.

> What would we add to where? If we need to add something, I thought NOTICE made sense, but I’m not very clear on these things.

Your would add a pointer to license text in the LICENSE file. [1]

Thanks,
Justin

1. http://www.apache.org/dev/licensing-howto.html#permissive-deps

Re: Encode and Decode UTF8

Posted by Harbs <ha...@gmail.com>.
Yes. It is.

I’m going to change it.

On Jul 3, 2016, at 8:29 AM, Alex Harui <ah...@adobe.com> wrote:

> 
> 
> On 7/2/16, 12:22 PM, "Harbs" <ha...@gmail.com> wrote:
> 
>> Thanks. The GC implementation is nice and simple.
>> 
>> One question (I think for Peter):
>> 
>> BinaryData is using Int8Array for the view. is there a reason that it’s
>> not using Uint8Array?
> 
> I think it should probably use Uint8Array if it is available everywhere.
> 
> -Alex
> 


Re: Encode and Decode UTF8

Posted by Alex Harui <ah...@adobe.com>.

On 7/2/16, 12:22 PM, "Harbs" <ha...@gmail.com> wrote:

>Thanks. The GC implementation is nice and simple.
>
>One question (I think for Peter):
>
>BinaryData is using Int8Array for the view. is there a reason that it’s
>not using Uint8Array?

I think it should probably use Uint8Array if it is available everywhere.

-Alex


Re: Encode and Decode UTF8

Posted by Harbs <ha...@gmail.com>.
Thanks. The GC implementation is nice and simple.

One question (I think for Peter):

BinaryData is using Int8Array for the view. is there a reason that it’s not using Uint8Array?

Harbs

On Jul 1, 2016, at 8:15 PM, Alex Harui <ah...@adobe.com> wrote:

> Actually, I saw note saying that Google Closure Library has this
> capability, and it is under Apache License 2.0.  It is in the crypt.js but
> doesn't seem to have any crypto code in it, so it might be easier to copy
> it.
> 
> -Alex
> 
> 
> On 7/1/16, 7:39 AM, "Harbs" <ha...@gmail.com> wrote:
> 
>> Thanks for the links. I looks like the unlicensed license is a derivative
>> of the CC0 license, so if I’m reading it right, it’s binding and about as
>> permissive as you can get.
>> 
>> I’m not clear on what you are suggesting we do. I’d like to pretty much
>> include some of the code (with minor modifications) in an ActionScript
>> class. What would we add to where? If we need to add something, I thought
>> NOTICE made sense, but I’m not very clear on these things.
>> 
>> On Jul 1, 2016, at 4:47 PM, Justin Mclean <ju...@classsoftware.com>
>> wrote:
>> 
>>> Hi,
>>> 
>>>> Is there any problem just adopting the part of the code relevant to
>>>> UTF8? Do we need to add a notice?
>>> 
>>> Not that I can see but public domain is complex [1], but adding
>>> something to LICENSE is the current advice. It would be best to get [2]
>>> added to [3] and/or [1] by asking on legal discuss.
>>> 
>>> I can’t see any reason why it would not be added/accepted.
>>> 
>>> Thanks,
>>> Justin
>>> 
>>> 1. 
>>> http://www.apache.org/legal/resolved.html#can-works-placed-in-the-public-
>>> domain-be-included-in-apache-products
>>> 2. http://unlicense.org
>>> 3. http://www.apache.org/legal/resolved.html
>> 
> 


Re: Encode and Decode UTF8

Posted by Alex Harui <ah...@adobe.com>.
Actually, I saw note saying that Google Closure Library has this
capability, and it is under Apache License 2.0.  It is in the crypt.js but
doesn't seem to have any crypto code in it, so it might be easier to copy
it.

-Alex


On 7/1/16, 7:39 AM, "Harbs" <ha...@gmail.com> wrote:

>Thanks for the links. I looks like the unlicensed license is a derivative
>of the CC0 license, so if I’m reading it right, it’s binding and about as
>permissive as you can get.
>
>I’m not clear on what you are suggesting we do. I’d like to pretty much
>include some of the code (with minor modifications) in an ActionScript
>class. What would we add to where? If we need to add something, I thought
>NOTICE made sense, but I’m not very clear on these things.
>
>On Jul 1, 2016, at 4:47 PM, Justin Mclean <ju...@classsoftware.com>
>wrote:
>
>> Hi,
>> 
>>> Is there any problem just adopting the part of the code relevant to
>>>UTF8? Do we need to add a notice?
>> 
>> Not that I can see but public domain is complex [1], but adding
>>something to LICENSE is the current advice. It would be best to get [2]
>>added to [3] and/or [1] by asking on legal discuss.
>> 
>> I can’t see any reason why it would not be added/accepted.
>> 
>> Thanks,
>> Justin
>> 
>> 1. 
>>http://www.apache.org/legal/resolved.html#can-works-placed-in-the-public-
>>domain-be-included-in-apache-products
>> 2. http://unlicense.org
>> 3. http://www.apache.org/legal/resolved.html
>


Re: Encode and Decode UTF8

Posted by Harbs <ha...@gmail.com>.
Thanks for the links. I looks like the unlicensed license is a derivative of the CC0 license, so if I’m reading it right, it’s binding and about as permissive as you can get.

I’m not clear on what you are suggesting we do. I’d like to pretty much include some of the code (with minor modifications) in an ActionScript class. What would we add to where? If we need to add something, I thought NOTICE made sense, but I’m not very clear on these things.

On Jul 1, 2016, at 4:47 PM, Justin Mclean <ju...@classsoftware.com> wrote:

> Hi,
> 
>> Is there any problem just adopting the part of the code relevant to UTF8? Do we need to add a notice?
> 
> Not that I can see but public domain is complex [1], but adding something to LICENSE is the current advice. It would be best to get [2] added to [3] and/or [1] by asking on legal discuss.
> 
> I can’t see any reason why it would not be added/accepted.
> 
> Thanks,
> Justin
> 
> 1. http://www.apache.org/legal/resolved.html#can-works-placed-in-the-public-domain-be-included-in-apache-products
> 2. http://unlicense.org
> 3. http://www.apache.org/legal/resolved.html


Re: Encode and Decode UTF8

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

> Is there any problem just adopting the part of the code relevant to UTF8? Do we need to add a notice?

Not that I can see but public domain is complex [1], but adding something to LICENSE is the current advice. It would be best to get [2] added to [3] and/or [1] by asking on legal discuss.

I can’t see any reason why it would not be added/accepted.

Thanks,
Justin

1. http://www.apache.org/legal/resolved.html#can-works-placed-in-the-public-domain-be-included-in-apache-products
2. http://unlicense.org
3. http://www.apache.org/legal/resolved.html

Re: Encode and Decode UTF8

Posted by Harbs <ha...@gmail.com>.
Just to add:

There are JS APIs for this, namely TextEncoder[3] and TextDecoder[4], but browser support is incomplete. I would probably use these APIs for browsers which support them, and use the “borrowed” code as a fallback.

[3]https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder#Browser_compatibility
[4]https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder#Browser_compatibility

On Jul 1, 2016, at 2:39 PM, Harbs <ha...@gmail.com> wrote:

> We have a need to read and write UTF8 strings to “ByteArrays” in FlexJS. FlexJS already has a BinaryData class which can serve as a stand-in for ByteArray, but it’s missing reading and writing UTF8. I’d like to add these methods.
> 
> UTF8 gets a bit complicated when dealing with 2,3 and 4 byte characters. There’s a JS library which solves this problem already on GotHub[1]. The code was placed into public domain[2].
> 
> Is there any problem just adopting the part of the code relevant to UTF8? Do we need to add a notice?
> 
> Harbs
> 
> [1]https://github.com/inexorabletash/text-encoding/blob/master/lib/encoding.js
> [2]https://github.com/inexorabletash/text-encoding/blob/master/LICENSE.md