Reputation: 5147
For what reason I'm getting the same result:
groovy -e "println 'Hello'.getBytes('windows-1251')"
result
[72, 101, 108, 108, 111]
and
groovy -e "println 'Hello'.getBytes('UTF-8')"
result is the same
[72, 101, 108, 108, 111]
Upvotes: 0
Views: 87
Reputation: 13859
English letters, numbers, standard symbols and so on in almost every encoding keep's same codes.
It's true for ASCII first page. Symbols with codes 0-127. If you try any other letters, result will differ.
groovysh "println 'Привет'.getBytes('windows-1251')"
[-49, -16, -24, -30, -27, -14]
groovysh "println 'Привет'.getBytes('UTF-8')"
[-48, -97, -47, -128, -48, -72, -48, -78, -48, -75, -47, -126]
Upvotes: 3