Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid encoding of ö char #15

Open
Koziolek opened this issue Oct 23, 2015 · 2 comments
Open

Invalid encoding of ö char #15

Koziolek opened this issue Oct 23, 2015 · 2 comments

Comments

@Koziolek
Copy link

My code is simple:

$base64.encode($scope.loginText)

Now if I put ö as loginText then I get 9g== that is invalid. As a reference, and valid, encoding I use java:

import java.util.Base64;
//...
byte[] encode = Base64.getEncoder().encode("ö".getBytes());
System.out.println(new String(encode));

produces 'w7Y=

and python

>>> import base64
>>> base64.b64encode("ö")
'w7Y=

Similar issue for other chars from german language, some from spanish and polish.

@frazzaglia
Copy link

Same issue with some characters from alphabet turkish and polish (ex: "Müşteri").

@frazzaglia
Copy link

@Koziolek I can encode correctly your "ö". When I encode, I obtain "9g==".
My problem is related to "getByte" function in angular-base64.js file because function charCodeAt() return a value greater than 255 and an exception is thrown.
If I comment "if" the character is not encoded correctly.

 var x = s.charCodeAt(i);
  if (x > 255) {
      throw "INVALID_CHARACTER_ERR: DOM Exception 5";
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants