How to convert Big5 encoded text into UTF8 in Dart?

116 views
Skip to first unread message

何宗憲

unread,
Nov 24, 2014, 5:53:06 AM11/24/14
to mi...@dartlang.org
Hi All,
    I was trying to convert a web-based context, encoded in big5, into UTF8. However, I do not see dart:convert supports Big5 encoding yet. Could anyone suggest me an alternative?

    Also, I currently use iconv in javascript for this purpose but hopes to integrate all my functions into dart. I tried 'dart:js' but it has problem recognizing keyword 'require'. Please enlighten me up. Thanks! Here is my code in dart:

main.dart:

var js1 = new JsObject(context['jsFileStreamer'], ["../insurance.b5"]);
js1
.callMethod('receive', []);


A snippet of the jsFileStreamer is: 

var jsFileStreamer = function jsFileStreamer(FileName){

   
this.fileName = FileName;

   
// this function is to produce a file in csv format

   
this.receive = function(outName){
     
var iconv = require('iconv-lite');
 
};
};



Günter Zöchbauer

unread,
Nov 24, 2014, 6:09:46 AM11/24/14
to mi...@dartlang.org
There seems no package available yet which provides Big5 support.

When you use 'require' in your JavaScript code you need to load a JavaScript library that provides this function.
This is not an issue of 'dart:js'. See for example http://stackoverflow.com/questions/9901082/what-is-this-javascript-require

Alexandre Ardhuin

unread,
Nov 24, 2014, 6:11:35 AM11/24/14
to General Dart Discussion
Hi,

About the encoding problem see this similar question http://stackoverflow.com/a/26967535/634863

About the dart;js usage, it looks good. "require" is called on the js side, so you have to ensure this function is defined (by including http://requirejs.org/ ?).

Cheers,
Alexandre



--
For other discussions, see https://groups.google.com/a/dartlang.org/
 
For HOWTO questions, visit http://stackoverflow.com/tags/dart
 
To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.

kaop...@gmail.com

unread,
Nov 24, 2014, 7:45:39 AM11/24/14
to 何宗憲
Do you consider porting it to dart version?

從我的 BlackBerry 10 智慧型手機傳送。
寄件者: 何宗憲
已傳送: Monday, November 24, 2014 18:53
收件者: mi...@dartlang.org
回覆至: mi...@dartlang.org
主旨: [dart-misc] How to convert Big5 encoded text into UTF8 in Dart?

Reply all
Reply to author
Forward
0 new messages