http://gwt-code-reviews.appspot.com/516801/diff/1/4
File user/super/com/google/gwt/emul/java/lang/String.java (right):
http://gwt-code-reviews.appspot.com/516801/diff/1/4#newcode458
user/super/com/google/gwt/emul/java/lang/String.java:458: int n =
str.length();
On 2010/05/13 03:24:38, jat wrote:
Are you sure that is guaranteed to be UTF8? I would expect it to be
whatever
encoding the host page was in. Maybe that is the right behavior for
getBytes(),
but here I think we have to guarantee that it is UTF8.
encodeURIComponent and decodeURIComponent are guaranteed to be UTF-8,
per ECMA-262, and I ran Sputnik tests
<http://sputnik.googlelabs.com/run> in a few browsers, none of them
(including IE6) failed on this test:
http://code.google.com/p/sputniktests/source/browse/trunk/tests/Conformance/15_Native_ECMA_Script_Objects/15.1_The_Global_Object/15.1.3_URI_Handling_Function_Properties/15.1.3.4_encodeURIComponent/S15.1.3.4_A2.2_T1.js
Regarding getting the bytes, I suspect that you can do something like
str.split('') and then apply some function to the resulting array, but
I am not
really sure how that can be faster.
Yes I thought about this option as well. A benchmark would tell us
whether split('')+some function is faster than for-loop+charAt but I
don't think the difference would be worth the benchmark work (it's a
much less frequent use-case than StringBuilder for instance, for which
benchmarking string concat vs. array join was worth it).
http://gwt-code-reviews.appspot.com/516801/show
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors