javaandroidcharacter-encodingstreamhebrew

Metadata title in Hebrew displays as gibberish


I'm developing Android applications.

When writing code to get the streaming title "now loading" in Hebrew,I receive gibberish.

screenshot of "gibberish" text

        @Override
        protected IcyStreamMeta doInBackground(URL... urls)
        {
            try
            {
                streamMeta.refreshMeta();
                Log.e("Retrieving MetaData","Refreshed Metadata");
            }
            catch (IOException e)
            {
                Log.e(MetadataTask2.class.toString(), e.getMessage());
            }
            return streamMeta;
        }

        @Override
        protected void onPostExecute(IcyStreamMeta result)
        {
            try
            {
                title_artist=streamMeta.getTitle();
                Log.e("Retrieved title_artist", title_artist);
                if(title_artist.length()>0)
                {
                    textView.setText(title_artist);
                }
            }
            catch (IOException e)
            {
                Log.e(MetadataTask2.class.toString(), e.getMessage());
            }
        }
    }

    class MyTimerTask extends TimerTask {
        public void run() {
            try {
                streamMeta.refreshMeta();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                String title_artist=streamMeta.getTitle();
                Log.i("ARTIST TITLE", title_artist);
            } catch (IOException e) {
                e.printStackTrace();
            }


        }
    }
}

Solution

  • It looks like IcyMetaData simply casts raw bytes to char (effectively doing ISO-8859-1 encoding instead of using detecting whatever the server sends) at line 149:

    metaData.append((char) b);
    

    I don't see a way to fix this without patching/fixing the IcyMetaData class.