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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:35:23+00:00 2026-05-22T11:35:23+00:00

I parsing mp3 tags. String artist – I do not know what was on

  • 0

I parsing mp3 tags.

String artist – I do not know what was on the encoding

Ïåñíÿ ïðî íàäåæäó – example string in russian "Песня про надежду"

I use http://code.google.com/p/juniversalchardet/

code:

String GetEncoding(String text) throws IOException {
        byte[] buf = new byte[4096];


        InputStream fis = new ByteArrayInputStream(text.getBytes());


        UniversalDetector detector = new UniversalDetector(null);

        int nread;
        while ((nread = fis.read(buf)) > 0 && !detector.isDone()) {
            detector.handleData(buf, 0, nread);
        }
        detector.dataEnd();
        String encoding = detector.getDetectedCharset();
        detector.reset();
        return encoding;
    }

And covert

new String(text.getBytes(encoding), "cp1251"); -but this not work.

if I use utf-16

new String(text.getBytes("UTF-16"), "cp1251") return “юя П е с н я п р о н а д е ж д у” space – not is char space

EDIT:

this first read bytes

byte[] abyFrameData = new byte[iTagSize];
oID3DIS.readFully(abyFrameData);
ByteArrayInputStream oFrameBAIS = new ByteArrayInputStream(abyFrameData);

String s = new String(abyFrameData, “????”);

  • 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-22T11:35:24+00:00Added an answer on May 22, 2026 at 11:35 am

    Java strings are UTF-16. All other encodings can be represented using byte sequences. To decode character data, you must provide the encoding when you first create the string. If you have a corrupted string, it is already too late.

    Assuming ID3, the specifications define the rules for encoding. For example, ID3v2.4.0 might restrict the encodings used via an extended header:

    q – Text encoding restrictions

       0    No restrictions
       1    Strings are only encoded with ISO-8859-1 [ISO-8859-1] or
            UTF-8 [UTF-8].
    

    Encoding handling is defined further down the document:

    If nothing else is said, strings,
    including numeric strings and URLs,
    are represented as ISO-8859-1
    characters in the range $20 – $FF.
    Such strings are represented in frame
    descriptions as <text string>, or
    <full text string> if newlines are
    allowed. If nothing else is said
    newline character is forbidden. In
    ISO-8859-1 a newline is represented,
    when allowed, with $0A only.

    Frames that allow different types of
    text encoding contains a text encoding
    description byte. Possible encodings:

     $00   ISO-8859-1 [ISO-8859-1]. Terminated with $00.
     $01   UTF-16 [UTF-16] encoded Unicode [UNICODE] with BOM. All
           strings in the same frame SHALL have the same byteorder.
           Terminated with $00 00.
     $02   UTF-16BE [UTF-16] encoded Unicode [UNICODE] without BOM.
           Terminated with $00 00.
     $03   UTF-8 [UTF-8] encoded Unicode [UNICODE]. Terminated with
           $00.
    

    Use transcoding classes like InputStreamReader or (more likely in this case) the String(byte[],Charset) constructor to decode the data. See also Java: a rough guide to character encoding.


    Parsing the string components of an ID3v2.4.0 data structure would something like this:

    //untested code
    public String parseID3String(DataInputStream in) throws IOException {
      String[] encodings = { "ISO-8859-1", "UTF-16", "UTF-16BE", "UTF-8" };
      String encoding = encodings[in.read()];
      byte[] terminator =
          encoding.startsWith("UTF-16") ? new byte[2] : new byte[1];
      byte[] buf = terminator.clone();
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      do {
        in.readFully(buf);
        buffer.write(buf);
      } while (!Arrays.equals(terminator, buf));
      return new String(buffer.toByteArray(), encoding);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Parsing an array of string commands, I need to know if a string contains
I`m parsing a Google Maps RSS with javascript and using the following code to
I'm parsing text from a file and storing it in a string. The problem
I'm looking at parsing a delimited string, something on the order of a,b,c But
I am parsing an RSS feed from the following URL: http://rss.sciam.com/ScientificAmerican-Global?format=xml // $xml_text is
I'm trying to use fmodex 4.30.03 to play an MP3 file under Mono/Ubuntu. My
While parsing the XML with SAX parser in JAVA, I am not able to
When parsing a PDF, given a string (popped from the Tj or TJ operator
XML Parsing Error: no element found Location: http://localhost/rss/ Line Number 1, Column 1: However,
When parsing the <description> tags found in several RSS feeds, I'm noticing that if

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.