java - I am trying to read in .properties files with Chinese characters encoded in utf-8 -


i trying read .properties files having chinese characters. when read them using keys printing ??????. writing jsf application. need translation application in chinese. on ui in jsf showing characters correctly should be. in java code showing ?????. donot why is. tried "手提電話" , tried "\u88dc\u7fd2\u500b\u6848" , tried print them on console main function, printing correctly in chinese lang chars. properties file having encoding utf-8.

to clarify confusion it, able display them console in chinese

 string str="Алексей";     string str="\u88dc\u7fd2\u500b\u6848";     system.out.println("direct output: "+str); 

working fine in psvm. after reading using properties file shows ???.e hope clear now. database receiving ?? in place actual chinese charactersets.

please help. other clarification required please confirm can update lines on here.

here code reading properties file returns bundle of relevant locale.

 facescontext context = facescontext.getcurrentinstance();                     bundle = context.getapplication().getresourcebundle(context, "hardvalue"); 

after going call access value:

bundle.getstring("tutorsearch.header"); // results in ????? 

any other code need please confirm.

multiple question marks usually comes from

  • you had utf8-encoded data (good)
  • set names latin1 in effect (default, wrong)
  • the column declared character set latin1 (default, wrong)

for chinese (or emoji), need use mysql's utf8mb4.

the cure (for future inserts):

  • utf8-encoded data (good)
  • mysqli_set_charset('utf8mb4') (or whatever client needs establishing character set)
  • check column(s) and/or table default character set utf8mb4
  • if displaying on web page, <meta...charset=utf-8> should near top. (note different spelling.)

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -