Giter Site home page Giter Site logo

Comments (1)

tpwo avatar tpwo commented on August 26, 2024

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:

image

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):

image

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.