Added DataUtils.stringToUtf8Array. Use in Name to encode strings as utf8.
diff --git a/js/Name.js b/js/Name.js
index 1d28a81..5d6d4cb 100644
--- a/js/Name.js
+++ b/js/Name.js
@@ -38,7 +38,7 @@
for(var i=0;i<name.length;i++){
if(typeof name[i] == 'string')
- blobArrays[i]= DataUtils.toNumbersFromString( name[i] );
+ blobArrays[i]= DataUtils.stringToUtf8Array(name[i]);
else if(typeof name[i] == 'object')
blobArrays[i]= name[i] ;
else
diff --git a/js/encoding/DataUtils.js b/js/encoding/DataUtils.js
index eee178a..c725209 100644
--- a/js/encoding/DataUtils.js
+++ b/js/encoding/DataUtils.js
@@ -284,6 +284,13 @@
}
/*
+ * Encode str as utf8 and return as Uint8Array.
+ */
+DataUtils.stringToUtf8Array = function(str) {
+ return DataUtils.toNumbersFromString(str2rstr_utf8(str));
+}
+
+/*
* Return a new Uint8Array which is the Uint8Array concatenated with raw String str.
*/
DataUtils.concatFromString = function(array, str) {
diff --git a/js/testing/test-put-async.html b/js/testing/test-put-async.html
index 315dec8..f41658c 100644
--- a/js/testing/test-put-async.html
+++ b/js/testing/test-put-async.html
@@ -36,7 +36,7 @@
var si = new SignedInfo();
si.setFields();
- var answer = DataUtils.toNumbersFromString(content);
+ var answer = DataUtils.stringToUtf8Array(content);
var co = new ContentObject(new Name(nameStr), si, answer, new Signature());
co.sign();