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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:45:56+00:00 2026-06-01T04:45:56+00:00

A half-year ago i faced with annoying problem. And still couldn’t fix it. Problem

  • 0

A half-year ago i faced with annoying problem. And still couldn’t fix it.
Problem is lying in log4j-logging, where default charset is utf 8.

Sometimes i receiving messages with different encoding, CP1252. (There’s no way to change this).
Thus logging in utf8 makes the text unreadable.
I can fix the encoding somehow, and this text would be readable in the log.

But if i will apply that “encoding fix” to the normal message, it will be messed up.
I need to know if that conversion is really needed. Unfortunately, i have no ideas.

  • 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-01T04:45:57+00:00Added an answer on June 1, 2026 at 4:45 am

    As deceze commented there is no reliable way automatically detect encoding of a text.

    Most encodings try to use 1 byte for characters, as result same sequence of bytes mean totally different string in different encodings. Pretty much the only thing you can reliably do is to say that “it is not valid UTF8 string”, other frequently used encodings do not even have strict rules what byte sequences are/are not valid for it.

    You best option is to know encoding of the message. Next option would be to preserve text as byte array next to “utf8 string”.

    If you have very limited set of encodings to accept (utf8/utf16/cp1252) you can try to use some heuristics to detect – i.e. most English strings in UTF16 will have 0 as every other byte, and you can than try to see if the string is OK as UTF8 – if not – than it is likely the remaining encoding.

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

Sidebar

Related Questions

I started using the MVC pattern a half year ago, and I still have
Half a year ago, I tried Visual Studio 2010 Beta 1, but it was
About half year ago I decided to improve my programming efficiency, so I learned
I bought an iPod touch 3rd Gen half year ago, and I got recently
About half a year ago, when I started to learn Ruby and Rails, I
About half a year ago, I started digging into unit testing. I made my
So I similar question was asked about a year an half ago here: How
More than half a year ago, Oracle issued a Statement of Direction announcing that
I have an in-house iPhone app. Developed about a year and a half ago.
I made a jquery gallery a half year ago (SO community helped me alot

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.