Comments (3)
gbk is correct, utf-8 will have one more space in some environments
I found the problem. When dealing with wide characters, space adaptation should be added. Under gbk,
chcp 936
is normal here, and under utf-8chcp 65001
, there is one more space, and the logic of deleting and adding spaces is fine。So don't switch cmd to utf-8. (maybe it's just my local problem)
// https://github.com/nsf/termbox-go/blob/master/api_windows.go
if runewidth.RuneWidth(rune(char.char)) > 1 {
char.attr |= common_lvb_leading_byte
chars = append(chars, char)
// here
chars = append(chars, char_info{
char: char.char,
attr: char.attr | common_lvb_trailing_byte,
})
}
from termbox-go.
bug description:It seems that wide characters do not need to add spaces under UTF-8 encoding? (I verified it locally, not sure if it is the case on other platforms or other machines)
how to solve
- GBK:There is no problem
- UTF-8:just Delete lines 130 to 134
`https://github.com/nsf/termbox-go/blob/2ff630277754813b198ae96036e28e254d2c72bf/api_windows.go`` - ABOUT:Doing so may cause problems on mac or other platforms? No test, only for win platform
expected:Is it possible to judge whether the current chcp is equal to 65001 (UTF-8), and consider adding spaces? [I know that there may be many encoding formats that are inconvenient to adapt, just ask questions when encountering this situation]
related environment
platform:windows
terminal: cmd | vscode| goland
from termbox-go.
I do not have this problem when using tbprint.
https://github.com/ydzhou/pine/blob/f69443a87ad8c6754e305415dee930447fcdbb9f/internal/renderUtil.go#L55
My editor can print Chinese or other UTF-8 characters as expected (without any spacing in-between)
from termbox-go.
Related Issues (20)
- tmux-256color $TERM unsupported
- panic: The handle is invalid. HOT 1
- Keybindings not working on FreeBSD HOT 2
- Wine panics ("Invalid handle")
- build failure on gnu/hurd HOT 3
- Understanding character codes / sequences HOT 3
- Copy-pastable line wrap HOT 2
- Version tagging HOT 1
- Panic on FreeBSD host HOT 5
- ShowCursor Function
- Save current history/screen in plain text HOT 4
- Why output is ahead of my command rather than after?
- can it support emoji HOT 1
- Chinese characters support issue HOT 1
- KeyEnter and KeyCtrlM map to the same Hex value HOT 1
- how to use with custom pty example ssh
- How do I detect a double-click mouse event?
- Add support for SetOutputMode other than OutputNormal for Windows Terminal
- [RFE] AIX support
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 termbox-go.