2012-02-23 6 views
0

"res \ raw"폴더에 저장된 ".HTML"파일이 있습니다. 가 내 파일의 내용을 표시하려면 다음 코드를 사용 : 나는 그래서 어떻게해야합니까 '무엇이든, 그것은 "와 같은 특수 문자를 표시하지 않는 인코딩 유형이거나 지금웹 페이지에 특수 문자가 표시되지 않습니다.

static String TAG="WebPageShowActivity"; 
    WebView mWebView; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.webpagedisplay); 
     String summary = readRawTextFile(this,R.raw.spotlighterhelp); 
       //getResources().openRawResource(R.raw.spotlighterhelp).toString(); 
     mWebView = (WebView) findViewById(R.id.webview); 
     mWebView.getSettings().setJavaScriptEnabled(true); 
     mWebView.loadDataWithBaseURL (null,summary, "text/html","ASCII" ,null); 
    } 
    public static String readRawTextFile(Context ctx, int resId) 
    { 
      InputStream inputStream = ctx.getResources().openRawResource(resId); 

      InputStreamReader inputreader = new InputStreamReader(inputStream); 
      BufferedReader buffreader = new BufferedReader(inputreader); 
      String line; 
      StringBuilder text = new StringBuilder(); 

      try { 
      while ((line = buffreader.readLine()) != null) { 
       text.append(line); 
       } 
      } catch (IOException e) { 
       return null; 
      } 
      Log.e(TAG, "file content: "+text.toString()); 
      return text.toString(); 
    } 

을, 내 문제는 이러한 문자도 표시됩니다?

내가 enter image description here

+0

문제가 해결되었습니다. .doc 파일을 .html로 변환 했으므로 ""을 특수 문자 ""로 변환했습니다. 이제는 제대로 작동하고 있습니다. – Pallavi

답변

0

를 출력 얻고있다 다음 나는 그것이 작품, 당신의 웹보기 대신 ASCIIUTF-8를 사용하려고 할 수 있습니다 생각합니다.

mWebView.loadDataWithBaseURL (null,summary, "text/html","UTF-8" ,null); 
관련 문제