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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:54:55+00:00 2026-05-31T22:54:55+00:00

I’m facing a charset problem (UTF-8) in a java file hosted on Heroku. Better

  • 0

I’m facing a charset problem (UTF-8) in a java file hosted on Heroku.

Better explaining it using a small example:

// '…' UTF-8 encoding is 0xE2 0x80 0xA6
// stringToHex() outputs the HEX value to console/log
stringToHex(new String("…".getBytes(), "UTF-8"));

Now, everything works perfectly locally (Tomcat 7)—”0xE2 0x80 0xA6″ is output in the console.

When I try it on the staging server, hosted on Heroku (Jetty 7), “0xEF 0xBF 0xBD 0xEF 0xBF 0xBD 0xEF 0xBF 0xBD” is written to the log instead.

Both the servers are running java with the parameter “-Dfile.encoding=UTF-8” (so Charset.defaultCharset().toString() outputs “UTF-8” in both).

Can anyone help me solving this bizarre problem?

Thanks.

Update – forgot to say: all the files are encoded in UTF-8 and compiled using javac -encoding UTF-8

Update 2 – tried with ‘£’ instead of ‘…’ and on the staging server I get “0xEF 0xBF 0xBD 0xEF 0xBF 0xBD” instead of “0xC2 0xA3″… Seems like it’s always converting every single byte to “0xEF 0xBF 0xBD” (which corresponds to �)… ???

Update 3 – since Heroku is using Jetty, I tried using Jetty locally and everything is working perfectly.

Update 4 – here is my stringToHex() function:

private void stringToHex(String string) throws UnsupportedEncodingException {
    String result = "";
    String tmp;
    for(byte b : string.getBytes("UTF-8")) {
        tmp = Integer.toHexString(0xFF & b);
        if(tmp.length() == 1) {
            tmp += '0';
        }

        result += "0x" + tmp.toUpperCase() + " ";
    }

    logger.info(result);
}

To compile in UTF-8 I use the maven-compiler-plugin. pom.xml relevant part:

<plugins>
    ...
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
            <encoding>UTF-8</encoding>
        </configuration>
    </plugin>
    ...
</plugins>
  • 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-31T22:54:56+00:00Added an answer on May 31, 2026 at 10:54 pm

    The problem was due to the AspectJ configuration. If you want to use AspectJ with Java and Spring you have to specify the encoding in the plugin configuration:

    <plugins>
        ...
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <version>1.0</version>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjrt</artifactId>
                    <version>1.6.10</version>
                </dependency>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjtools</artifactId>
                    <version>1.6.10</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>test-compile</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <outxml>true</outxml>
                <verbose>true</verbose>
                <showWeaveInfo>true</showWeaveInfo>
                <aspectLibraries>
                    <aspectLibrary>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-aspects</artifactId>
                    </aspectLibrary>
                </aspectLibraries>
                <source>1.6</source>
                <target>1.6</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        ...
    </plugins>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.