1

i need the same byte in Java

Encoding.Unicode.GetBytes("asd") //{97, 0, 115, 0, 100, 0} C#
"asd".getBytes() //{97, 115, 100} Java
1
  • Check what kind of encoding is being done on each platform Commented Oct 16, 2015 at 16:47

1 Answer 1

9

You're calling getBytes in Java without passing any charset, so it's using the default one. You want something like:

byte[] bytes = "asd".getBytes(StandardCharsets.UTF_16LE);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.