With android devices, the value is transmitted to the site through a link, the Russians are replaced with ??? and are recorded in the database too ???, how can I fix it so that Russian values ​​can be transmitted?

Code to send data from android:

find_btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { login_txt_find = find_txt.getText().toString(); find_txt.setText(""); full_url = url_regAcc+"login="+login_txt_find; new Show().execute(); } }); public class Show extends AsyncTask<Void, Void, String> { @Override protected String doInBackground(Void... params) { try { URL url = new URL(full_url); Scanner in = new Scanner((InputStream) url.getContent()); result = in.nextLine(); } catch (Exception e) { result = e.toString(); } return result; } @Override protected void onPostExecute(String strJson) { super.onPostExecute(strJson); try { if(Objects.equals(result, "7")) //Не подходит { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.java_find_txt1) .setCancelable(false) .setPositiveButton(R.string.java_find_txt2, null); AlertDialog alert = builder.create(); alert.show(); }else { JSONObject jObject = new JSONObject(result); login_prof_txt = jObject.getString("login"); name_prof_txt = jObject.getString("name"); surname_prof_txt = jObject.getString("surname"); age_prof_txt = jObject.getString("age"); city_prof_txt = jObject.getString("city"); country_prof_txt = jObject.getString("country"); String login_string = getString(R.string.java_string_login); String age_string = getString(R.string.java_string_age); info_login = login_string+login_prof_txt; info_name_surname = name_prof_txt+" "+surname_prof_txt; info_age = age_string+age_prof_txt; info_city = city_prof_txt; info_country = country_prof_txt; show_user(); } } catch (JSONException e) { e.printStackTrace(); } } 
  • Well ... It is necessary to correct the encoding. But where - we do not know, because You are the code, those are its places where the encodings are not shown. - YurySPb
  • Well, where is it generally put in android? In .htaccess UTF-8, in NotePad UTF-8, In utf-8 DB general ci - BeginnerProgrammer
  • I understand this a little, but I have a similar problem solved by the fact that in the php script the encoding of the connection to the database via PDO should have been written without a dash, i.e. UTF8 , instead of utf-8 - YuriSPb
  • And in android, it seems, by default, utf-16 stands and automatically turns into utf-8 . Whereupon, I think, the problem is not on the side of the android. - Yuriy SPb
  • And yes - try UTF8_unicode_ci instead of general for the database to put down - YuriySPb

1 answer 1

To specify the encoding you need to specify in the constructor parameters: http://developer.android.com/reference/java/util/Scanner.html#Scanner(java.io.File , java.lang.String)

  Scanner in = new Scanner((InputStream) url.getContent(), "UTF-8"); 

But in general, I highly recommend using okhttp, or HttpURLConnection