Giter Site home page Giter Site logo

Comments (2)

Dazzar56 avatar Dazzar56 commented on June 7, 2024

Вообще, как я заметил, этот подход предпочитают многие популярные консольные приложения.
Например NeoVim еще год назад выпилил у себя все wcwidth(). Цитата мейнтейнера:

I wouldn't trust libc wchar functions over our own stuff in ten thousand years. There are good c unicode libraries out there we should consider (like libutf8proc and libgrapheme), but glibc or anything contaminated by the POSIX standard is not.

Вместо этого они при каждой сборке скачивают свежие таблицы с https://unicode.org/Public/UNIDATA/ и на Lua генерируют константные таблицы.
В коде выглядит это так:
https://github.com/neovim/neovim/blob/4946489e2e3eeca5c831faf9fe86cbf1229701e2/src/nvim/mbyte.c#L471-L507

У NeoVim огромное комьюнити, которое непрерывно развивает этот редактор. Так что они уже давно набили все возможные шишки с поддержкой юникода и каких-либо артефактов отрисовки там очень давно не встречалось. Стоит присмотреться к их кодовой базе получше. Конкретно в этом файле как раз собраны все функции работы с юникодом.

from far2l.

TrNullFree avatar TrNullFree commented on June 7, 2024

FYI
I looked at far3. It takes (file char_width.cpp ) a ready-made table from the Windows Terminal sources (file src\types\CodepointWidthDetector.cpp ). And WT takes it from a file generated by the CodepointWidthsFromUCD.ps1 script .
The CodepointWidthsFromUCD.ps1 script generates code based on Unicode UCD XmlDocument "ucd.nounihan.flat.xml"
The script uses 3 overrides (overrides width to 1):

      <override first-cp="2500" last-cp="259F" ea="H" comment="box-drawing and block elements require 1-cell alignment" />
      <override first-cp="4DC0" last-cp="4DFF" ea="H" comment="hexagrams are historically narrow" />
      <override first-cp="FE20" last-cp="FE2F" ea="H" comment="narrow combining ligatures (split into left/right halves, which take 2 columns together)" />

from far2l.

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.