Unicode issue in tooltips on Jupyter notebook
See original GitHub issueMVP:
import folium
map_osm = folium.Map()
folium.GeoJson('{ "type": "Feature", "properties": { "name": "5/7, Линейная улица, Berdsk, Berdsk municipality, Novosibirsk Oblast, Siberian Federal District, 633011, Russia" }, "geometry": { "type": "Point", "coordinates": [ -75.849253579389796, 47.6434349837781 ] }}', name="5/7, Линейная улица, Berdsk, Berdsk municipality, Novosibirsk Oblast, Siberian Federal District, 633011, Russia", tooltip="5/7, Линейная улица, Berdsk, Berdsk municipality, Novosibirsk Oblast, Siberian Federal District, 633011, Russia").add_to(map_osm)
display(map_osm)
I’m running in Jupyter Lab with Python3.7 and latest Folium version (0.10.1+28.ga8ec61d which is with my PR)
Is there a workaround for this?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:11
Top Results From Across the Web
pygal charts not displaying tooltips in Jupyter / IPython notebook
My workaround involved setting up the HTML with the necessary javascript and chart svg like so: import pygal from IPython.display import ...
Read more >Tab Completion & Tooltip shortcut in Jupyter Notebook
Jupyter Notebook Tips and Tricks | Tab Completion & Tooltip shortcut in Jupyter NotebookShortcut for 1. Tab2. Shift + Tab Key3.
Read more >Jupyter Notebook Documentation, Release 6.5.0.dev0
Remove deprecated encoding parameter for Python 3.9 compatibility. ... Tooltips visible through keyboard navigation for specified buttons ...
Read more >Tooltip Encoding Issue - ADocLib
Describe the bug When hovering over a function there is a tooltip shown which contains ... Unicode issue in tooltips on Jupyter notebook...
Read more >0.13 Series — IPython 3.2.1 documentation
The IPython Notebook, which has proven since its release to be wildly ... While this hides all error reporting, once you have a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A fix has been merged in the branca library. It will be availabe in the next release, release date yet unknown. If you want it earlier you can install branca from the git main branch:
pip install git+https://github.com/python-visualization/branca.git@master
I think I found the issue. In branca we encode the html for in the notebook. This uses
encode('utf-8')
. A unicode string like"5/7, Линейная улица, Berdsk"
is turned into bytesb'5/7, \xd0\x9b\xd0\xb8\xd0\xbd\xd0\xb5\xd0\xb9\xd0\xbd\xd0\xb0\xd1\x8f \xd1\x83\xd0\xbb\xd0\xb8\xd1\x86\xd0\xb0, Berdsk'
. This is then base64 encoded.When the notebook rehydrates this code it uses
atob
to do base64 decoding. This function does not convert those characters to the right representations:Ð\u009bинейнаÑ\u008f Ñ\u0083лиÑ\u0086а
. I’m no expert on JS but I think it uses a default charset of utf-16.The solution is to encode the html not as utf-8, but using
raw_unicode_escape
. This converts"5/7, Линейная улица, Berdsk"
intob'5/7, \\u041b\\u0438\\u043d\\u0435\\u0439\\u043d\\u0430\\u044f \\u0443\\u043b\\u0438\\u0446\\u0430, Berdsk'
which results in proper dehydrated html in the browser.I’ll open a PR in branca with this fix. You could really help by testing that fix!