Answer the question
In order to leave comments, you need to log in
How to solve encoding problem in jsoup?
In my application, I parse content from an html page using the jsoup library, the link to this page consists of Russian and Latin characters (Cyrillic characters as a get-request parameter). The problem is that jsoup does not see the Cyrillic part of the link and the content is not parsed. When a full link is displayed in the log, the link is displayed like this:
I tried to change the encoding of the Cyrillic part using URLEncoder (in utf-8), now percentages and numbers appear instead of Cyrillic. The link in the log opens normally through the computer browser, but parsing still does not occur. I can't figure out what's wrong.
private String mCurrentGroup;
private final String mLink = "http://mai.ru/education/schedule/detail.php?group=";
private String mWeek = "1";
private final String PLUS_WEEK = "&week=";
mCurrentGroup = mSharedPreferences.getString(getString(R.string.pref_group), ""); //получаем кириллический параметр get-запроса
//"собираем полную ссылку и меняем кодировку у кириллической части, подключаемся
doc = Jsoup.connect(mLink.concat(URLEncoder.encode(mCurrentGroup, "utf-8")).concat(PLUS_WEEK).concat(mWeek)).get();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question