cpbotha / nvpy

Simplenote syncing note-taking application, inspired by Notational Velocity and ResophNotes, but uglier and cross-platformerer.
Other
849 stars 114 forks source link

nvpy doesn't support emoji in the note title #150

Closed johnolinda closed 5 years ago

johnolinda commented 7 years ago

When you have a note with an emoji character as part of the title (which is possible in the first-party clients) it produces this:

Traceback (most recent call last):
  File "/home/john/.local/bin/nvpy", line 11, in <module>
    load_entry_point('nvpy==1.0.0', 'gui_scripts', 'nvpy')()
  File "/home/john/.local/lib/python2.7/site-packages/nvpy/nvpy.py", line 734, in main
    controller = Controller(config)
  File "/home/john/.local/lib/python2.7/site-packages/nvpy/nvpy.py", line 306, in __init__
    self.notes_list_model.set_list(nn)
  File "/home/john/.local/lib/python2.7/site-packages/nvpy/nvpy.py", line 196, in set_list
    self.notify_observers('set:list', None)
  File "/home/john/.local/lib/python2.7/site-packages/nvpy/utils.py", line 207, in notify_observers
    o(self, evt_type, evt)
  File "/home/john/.local/lib/python2.7/site-packages/nvpy/view.py", line 1483, in observer_notes_list
    self.set_notes(notes_list_model.list)
  File "/home/john/.local/lib/python2.7/site-packages/nvpy/view.py", line 1584, in set_notes
    self.notes_list.append(o.note, utils.KeyValueObject(tagfound=o.tagfound))
  File "/home/john/.local/lib/python2.7/site-packages/nvpy/view.py", line 304, in append
    self.text.insert(tk.END, title, ("title,"))
  File "/usr/lib64/python2.7/lib-tk/Tkinter.py", line 3110, in insert
    self.tk.call((self._w, 'insert', index, chars) + args)
_tkinter.TclError: character U+1f310 is above the range (U+0000-U+FFFF) allowed by Tcl

I'm not necessarily saying we need emoji support (mine was in there by accident) but I did want to make sure the error was noted in case it's an easy fix.

yuuki0xff commented 7 years ago

This problem occurs by tcl/tk. This problem can be solve to 2 ways:

  1. Install ActivePython. It bundled module seem to support emoji.
  2. Rebuild tcl, tk and python packages with CFLAGS=-DTCL_UTF_MAX=6 --enable-unicode=ucs4 options. For your reference, i used build script is like this.
# build.sh
export CFLAGS=-DTCL_UTF_MAX=6

tar xf tcl8.6.6-src.tar.gz
tar xf tk8.6.6-src.tar.gz
git clone https://github.com/python/cpython

cd tcl8.6.6/unix
./configure --enable-threads --enable-shared --enable-symbols --enable-64bit --enable-langinfo --enable-man-symlinks
make
sudo checkinstall
cd ../..

cd tk8.6.6/unix
./configure --enable-threads --enable-shared --enable-symbols --enable-64bit --enable-man-symlinks
make
sudo checkinstall
cd ../..

cd cpython
git checkout -b 2.7 remotes/origin/2.7
./configure --enable-shared --enable-optimizations --enable-ipv6 --enable-unicode=ucs4 --with-lto --with-signal-module --with-pth --with-wctype-functions --with-tcltk-includes=/usr/local/include/ --with-tcltk-libs=/usr/local/lib/
make
sudo checkinstall
yuuki0xff commented 5 years ago

Added feature that notify users of UCS-4 issue. It will prevent user confusion.

5371ed34952a7152a5f45df4091c7ce51e087b02...992a40c59eff3e0c1a62d45a90d91a412b501ada