c# - "ISO-8859-1" Encoding in javascript -
i've created base64 encoding string
in following format using c#. want create same encoded string using javascript.
var isoencoding = system.text.encoding.getencoding("iso-8859-1"); var = isoencoding.getbytes(username + ":" + password); string encoded = system.convert.tobase64string(a); request.headers.add("authorization", "basic " + encoded);
here used iconv
, try encoded string
, gives differen encoded string. can reason?
var str = this.username+':'+this.password; var s = iconv.encode(str, 'iso-8859-1'); var = btoa(s.tostring()); headers.append('authorization', 'basic ' + a);
use instead of btoa
:
var = s.tostring('base64');
the default encoding buffer.tostring
utf-8
Comments
Post a Comment