Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 703989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:53:30+00:00 2026-05-14T03:53:30+00:00

I made the following simulation: byte[] b = new byte[256]; for (int i =

  • 0

I made the following “simulation”:

byte[] b = new byte[256];

for (int i = 0; i < 256; i ++) {
    b[i] = (byte) (i - 128);
}
byte[] transformed = new String(b, "cp1251").getBytes("cp1251");

for (int i = 0; i < b.length; i ++) {
    if (b[i] != transformed[i]) {
        System.out.println("Wrong : " + i);
    }
}

For cp1251 this outputs only one wrong byte – at position 25.
For KOI8-R – all fine.
For cp1252 – 4 or 5 differences.

What is the reason for this and how can this be overcome?

I know it is wrong to represent byte arrays as strings in whatever encoding, but it is a requirement of the protocol of a payment provider, so I don’t have a choice.

Update: representing it in ISO-8859-1 works, and I’ll use it for the byte[] part, and cp1251 for the textual part, so the question remains only out of curiousity

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:53:30+00:00Added an answer on May 14, 2026 at 3:53 am

    Some of the “bytes” are not supported in the target set – they are replaced with the ? character. When you convert back, ? is normally converted to the byte value 63 – which isn’t what it was before.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Very simple question, I made the following program : #include <stdlib.h> int main(int argc,
I've made following protection for my variables: $ad_title=htmlentities($ad_title); $ad_title=mysql_real_escape_string($ad_title); $ad_title=stripslashes($ad_title); But every time I
I have created a sitecollection and in AAM I have made following settings for
I made the following graph with the command boxplot(tstats,names=c(expression(bar(x)),,med(x),,mad(x),, var(x),,expression(q[.75]-q[.25]),), col=rep(c(wheat,chocolate),5)) abline(h=2,col=steelblue,lty=2) abline(h=-2,col=steelblue,lty=2) title(main=normal
I have made the following regexp for extracting robots links: re.compile(r/\S+(?:\/+)) And i get
In my Fortran code I made the following call to the dnrm2 routine: d
I've been playing with a jQuery grid control, and made the following change to
Following on from a post I made earlier, I am making progress with what
Following on from a comment I made on this: passing std::vector to constructor and
I have the following situation, I want to monitor the system calls on Android

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.