I created the following jsp:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<%
byte[] oe1 = {-61,-123};
byte[] oe2 = {-123,-61};
byte[] oe3 = "œ".getBytes("UTF-8");
%>
byte[] oe1 = {-61,-123}: '<%=new String(oe1, "UTF-8")%>'<br/>
byte[] oe2 = {-123,-61}: '<%=new String(oe2, "UTF-8")%>'<br/>
byte[] oe3 = "œ".getBytes("UTF-8"): '<%=new String(oe3, "UTF-8")%>'<br/>
oe3[0], oe3[1]: <%=oe3[0]%>, <%=oe3[1]%>
</body>
</html>
Prints the following:
byte[] oe1 = {-61,-123}: ' '
byte[] oe2 = {-123,-61}: '??'
byte[] oe3 = "œ".getBytes("UTF-8"): 'œ'
oe3[0], oe3[1]: -61, -123
What I miss here. Why oe3 works, but not oe1 or oe2. Maybe something is happening here with an encoding that I don't understand.
source
share