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 8521939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:58:04+00:00 2026-06-11T06:58:04+00:00

I have an array of bytes that contains a sentence. I need to convert

  • 0

I have an array of bytes that contains a sentence. I need to convert the lowercase letters on this sentence into uppercase letters. Here is the function that I did:

 public void CharUpperBuffAJava(byte[] word) {
     for (int i = 0; i < word.length; i++) {
        if (!Character.isUpperCase(word[i]) && Character.isLetter(word[i])) {
            word[i] -= 32;
        }
     }
    return cchLength;
 }

It will work fine with sentences like: “a glass of water”. The problem is it must work with all ANSI characters, which includes “ç,á,é,í,ó,ú” and so on. The method Character.isLetter doesn’t work with these letters and, therefore, they are not converted into uppercase.

Do you know how can I identify these ANSI characters as a letter in Java?

EDIT

If someone wants to know, I did method again after the answers and now it looks like this:

public static int CharUpperBuffAJava(byte[] lpsz, int cchLength) {
    String value;
    try {
        value = new String(lpsz, 0, cchLength, "Windows-1252");
        String upperCase = value.toUpperCase();
        byte[] bytes = upperCase.getBytes();
        for (int i = 0; i < cchLength; i++) {
            lpsz[i] = bytes[i];
        }
        return cchLength;
    } catch (UnsupportedEncodingException e) {
        return 0;
    }
}
  • 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-06-11T06:58:05+00:00Added an answer on June 11, 2026 at 6:58 am

    You need to “decode” the byte[] into a character string. There are several APIs to do this, but you must specify the character encoding that is use for the bytes. The overloaded versions that don’t use an encoding will give different results on different machines, because they use the platform default.

    For example, if you determine that the bytes were encoded with Windows-1252 (sometimes referred to as ANSI).

    String s = new String(bytes, "Windows-1252"); 
    String upper = s.toUpperCase();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a byte array that contains 6 bytes last 2 represents the port
I have WCF service that returns an object that contains an array of bytes
I have a character array that contains serialized data that I need to interpret
If (in zsh) I have an array that contains something like this: echo ${fsizes[@]}
I have a byte array that may or may not have null bytes at
I have a byte that is an array of 30 bytes, but when I
I have an array of bytes in my C# class, and need to persist
I have the following problem. I have an array of bytes that I want
I have an array result that contains values from 0-255. I originally declared it
I have a SQL database that contains images stored as a byte array. I

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.