Comments (1)
The root cause of the problem is the fact that vim from git bash on Windows seems to not support emojis. When I try to paste 😉
, <de09>
appears instead, and Python raises the exception with invalid continuation byte
when trying to save the file.
<de09>
seems to be something that is called surrogate:
And surrogate is something more complicated:
UCS uses surrogates to address characters outside the initial Basic Multilingual Plane without resorting to more-than-16-bit byte representations.
But it seems that it's wrong, because if saved externally in vim (i.e. outside pyzet) it cannot print correctly in the terminal:
> cat .\surrogate-test
This is surrogate test:
���
What is more interesting, is the fact that git bash's vim actually can open a file with emoji -- the problem lies only in pasting from external source (because it can yank and paste line with emoji without issues):
Vim from WSL2 works fine when pasting emojis, and it shares exactly the same configuration file. A quick search told me that the issue might be in locale
setting. IDK how it's done in git bash, but it's the hint for the further searching.
One of the workarounds is to actually use vim from WSL2 in pyzet. WSL2 adds command bash that is visible from PowerShell and I found a way to run Vim with the help of it:
# run Linux Substystem "vim" program like it's a normal Windows program
# something like an alias but really a shortcut to Windows Linux Subsystem vim application
function vim ($File){
# XXX: need to allow variable length argument list so "vim" can be passed options
$File = $File -replace '\\', '/'
bash -c "vim -- '$File'"
}
But WSL2 is not as standard as git bash, so I don't like this solution that much.
I'm leaving this issue open for now. I'm not using emojis that much, and they will appear practically only when pasting text authored by someone else. For now, it'd need some input sanitation before trying to save the file.
from pyzet.
Related Issues (20)
- Installation instructions are too hidden in the readme
- Add `keywords` to `setup.cfg`
- Extend `pyzet sample-config` to provide sane defaults also for Windows
- Add issue links in the changelog HOT 1
- `pyzet init foo` fails with `AttributeError: 'str' object has no attribute 'exists'`
- Add `pyzet remote` command
- Allow for changing the initial branch name in `pyzet init`
- Allow for ZK layout without `zettels` folder HOT 1
- Allow for optional zettel title passed with `pyzet add` HOT 1
- `OSError: [Errno 36] File name too long` when opening zettels HOT 1
- `pyzet grep -t` shows every line which starts with `#` HOT 1
- Support extended regular expressions in `pyzet grep` HOT 1
- `pyzet remote`: include `-v` flag by default
- Move 'Zettel formatting rules and guidelines' to a separate Markdown file HOT 1
- Simplify 'Supported editors' section HOT 1
- Auto-squash commits after multiple edits to the same zettel in a row HOT 2
- Get rid of `git` config field
- Allow for passing editor CLI arguments
- [pyzet remote] Convert SSH remote URLs into HTTPS URLs
- Allow for auto-downloading of images referenced with Markdown syntax
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyzet.