question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebView ignores document lang / encoding

See original GitHub issue

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment: OS: Windows 10 Node: 9.3.0 Yarn: 1.3.2 npm: 5.5.1 Watchman: Not Found Xcode: N/A Android Studio: Version 3.0.0.0 AI-171.4443003

Packages: (wanted => installed) react: 16.0.0 => 16.0.0 react-native: 0.51.0 => 0.51.0

Steps to Reproduce

(Write your steps here:)

  1. Init a new project.
  2. Copy/Paste the code I provide.
  3. See - the characters are wrong.

Expected Behavior

Show the word in Hebrew:

שלום

Actual Behavior

Shows some bad characters.

image

Reproducible Demo

Link: https://snack.expo.io/HkmOZ0VHG

If it’s not a bug then how can I achieve this relatively simple task of setting the encoding to Hebrew? I’ve search all over the internet, as well as the docs and this very repo issue tracker 😃

Thank you!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

5reactions
4externalcommented, Jan 25, 2018

try add baseUrl:‘’

  render() {
    const theText = decodeURIComponent("%D7%A9%D7%9C%D7%95%D7%9D")

  const htmlSrc = `
<!DOCTYPE html>
<html lang="he">
<head>
<meta charset="utf-8">
<title>The Title</title>
</head>

<body>
${theText}
</body>

</html>
    `

    // Case 1: No encoding set, just passing a string in Hebrew
    // return <WebView source={{ html: theText }} />

    // Case 2: Setting encoding in a fully fledged HTML5 document
    return <WebView source={{ html: htmlSrc, baseUrl:'' }} />
  }
1reaction
elyrancommented, Jan 28, 2018

Thanks @4external . For others: Check out react-native-htmlview .

For the team: Isn’t that a bug, though? Adding ‘baseUrl’ as an empty string sounds like a workaround…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Encoding issue with WebView's loadData - android
This works flawlessly, especially on Android 4.0, which apparently ignores character encoding inside HTML. Tested on 2.3 and 4.0.3.
Read more >
WebView - Android Developers
public class WebView ... Use createPrintDocumentAdapter(java.lang. ... Check whether this ViewGroup should ignore focus requests for itself and its children ...
Read more >
URL Standard
In HTML, when the document encoding is a legacy encoding, code points in the URL-query string that are higher than U+007F DELETE will...
Read more >
Web Application Manifest - W3C
This specification defines a JSON-based file format that provides ... The manifest's lang member is a string in the form of a language...
Read more >
core/java/android/webkit/WebView.java - platform/frameworks ...
File ;. import java.lang.annotation.Retention; ... The {@code encoding} parameter specifies whether the data is base64 or URL. * encoded.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found