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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:55:08+00:00 2026-05-13T06:55:08+00:00

I tried to type char literals for accentuated vowels in Java, but the compilers

  • 0

I tried to type char literals for accentuated vowels in Java, but the compilers says something like: unclosed character literal

This is what I’m trying to do:

 char [] a = {'à', 'á', 'â', 'ä' };

I’ve tried using Unicode '\u00E0' but for some reason they don’t match with my code:

 for( char c : string.toCharArray() ) {
     if( c == a[i] ) {
         // I've found a funny letter 
     }
 }

The if never evaluates to true, no matter what I put in my string.

Here’s the complete program I’m trying to code.

  • 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-13T06:55:09+00:00Added an answer on May 13, 2026 at 6:55 am

    The code should be compiled with the correct encoding:

    javac -encoding UTF-8 Foo.java
    

    There’ll be an encoding mismatch there somewhere.

    public class Foo {
      char [] a = {'à', 'á', 'â', 'ä' };  
    }
    

    The above code saved as UTF-8 should become the hex dump:

    70 75 62 6C 69 63 20 63 6C 61 73 73 20 46 6F 6F         public class Foo
    20 7B 0D 0A 20 20 63 68 61 72 20 5B 5D 20 61 20          {__  char [] a
    3D 20 7B 27 C3 A0 27 2C 20 27 C3 A1 27 2C 20 27         = {'__', '__', '
    C3 A2 27 2C 20 27 C3 A4 27 20 7D 3B 20 20 0D 0A         __', '__' };  __
    7D 0D 0A 0D 0A                                          }____
    

    The UTF-8 value for code point U+00E0 (à) is C3 A0.

    The code should be compiled with the correct encoding:

    javac -encoding UTF-8 Foo.java
    

    There is an outside chance that à will be represented by the combining sequence U+0061 U+0300. This is the NFD form (I’ve never come across a text editor that used it as a default for text entry). As Thorbjørn Ravn Andersen points out, it is often better to always use \uXXXX escape sequences – it is less ambiguous.

    You also need to check your input device (file/console/etc.)

    As a last resort, you can dump your chars as hex System.out.format("%04x", (int) c); and try manually decoding them with a character inspector to find out what they are.

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

Sidebar

Related Questions

Tried something like this: HttpApplication app = s as HttpApplication; //s is sender of
Type mismatch. Expecting a LexBuffer<char> but given a LexBuffer<byte> The type 'char' does not
Tried to map it from Preferences -> Settings -> Keyboard, but the key combo
I tried scouring the web for help on this issue, but there are so
I tried to package a Twisted program with py2exe, but once I run the
I tried but I guess Message Box only works with win forms. What is
I tried x = y ** e, but that didn't work.
I have a method with an out parameter that tries to do a type
I tried to install Delphi 7 on Vista several times and Vista prevented me
I tried recently to use NAnt (beta 0.86.2962.0) to run some unit tests compiled

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.