Comments (16)
I solved this issue based on this answer,
The solution is:export LC_CTYPE="en_US.UTF-8"
from lipgloss.
@Qrnbth have you tried
os.Setenv("RUNEWIDTH_EASTASIAN", "0")
?
No,I think it's not the argument issue if you had a glance on the source code in go-runewidth ,
more like the console needs to restart to take effect
The best way that I know so far is to set up the enviroment manually in system enviroment
or using other console emulator like Windows Terminal ,Tabby or some other font-compatible ones.
But it just not good enough if you wanna distribute your works with these dumb solutions I suppose
from lipgloss.
@meowgorithm How to force terminal to run with this certain enviroment without configuring environment manually? I tried
os.Setenv("RUNEWIDTH_EASTASIAN", "true") os.Setenv("LC_CTYPE", "en_US.UTF-8")before executing the main app, but that didn't work, any nice solution?
In the source code of github.com/mattn/go-runewidth
, it obtains the RUNEWIDTH_EASTASIAN
environment variable using the init()
function.
According to the execution order of init()
in Golang, you can create a separate conf
package in your project, and set the RUNEWIDTH_EASTASIAN
environment variable in the init()
function within this package. Then, you can import the conf
package in the main
package.
Just ensure that the conf
package is the first in the import list of the main package, and it will take effect.
package conf
import (
"os"
)
func init() {
os.Setenv("RUNEWIDTH_EASTASIAN", "0")
}
package main
import (
_ "project/conf"
"github.com/charmbracelet/bubbles/viewport"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/glamour"
"github.com/charmbracelet/lipgloss"
)
from lipgloss.
Also for reference: setting LC_CTYPE=zh_CN.UTF-8
recreates the behavior. Setting LC_CTYPE=zh_CN.UTF-8 RUNEWIDTH_EASTASIAN=0
corrects it.
from lipgloss.
Encodings like this are very difficult to deal with because there's technically no correct answer to how something should be configured. For such a common failure as this, it makes sense to include a link in the --help
of the application and in the readme. Basically just in as many places as the user may be looking at for assistance.
Now that this is known, it may also be worth while to pre-emptively check the value of that environment variable and see if there's a way to provide a warning to the user.
This isn't much different to other tools that, as an example, require a nerd font, in order to correctly display various icons and such.
from lipgloss.
Hi! I’m not able to reproduce this on any of my Macs. I suspect your terminal may not be using UTF-8 (see #30).
Would you mind running the locale
command and pasting the output here?
Also, to be thorough, what terminal emulator and font are you using? It appears to be Lucida Console in macOS stock terminal, though it would be good to verify this.
from lipgloss.
Hi! I’m not able to reproduce this on any of my Macs. I suspect your terminal may not be using UTF-8 (see #30).
Would you mind running the
locale
command and pasting the output here?Also, to be thorough, what terminal emulator and font are you using? It appears to be Lucida Console in macOS stock terminal, though it would be good to verify this.
locale
:
╰─$ locale
LANG="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_CTYPE="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_ALL=
from lipgloss.
my terminal is iTerm2, and the font I use is Monaco Regular
from lipgloss.
Okay, that’s good to know. Still, it would be good to figure out why things aren’t rendering properly under zh_CN.UTF-8
. If you don't mind I'm going to leave this issue open for now so we can hopefully solve for this.
from lipgloss.
Okay, that’s good to know. Still, it would be good to figure out why things aren’t rendering properly under
zh_CN.UTF-8
. If you don't mind I'm going to leave this issue open for now so we can hopefully solve for this.
Ok, I'll leave that question open
from lipgloss.
Thanks! Related: mattn/go-runewidth#14
from lipgloss.
Also for reference: setting
LC_CTYPE=zh_CN.UTF-8
recreates the behavior. SettingLC_CTYPE=zh_CN.UTF-8 RUNEWIDTH_EASTASIAN=0
corrects it.
This also works. When I set export RUNEWIDTH_EASTASIAN=0
, it is normal.
from lipgloss.
LC_CTYPE="ja_JP.UTF-8"
also causes incorrect rendering.
It can also be solved by export LC_CTYPE="en_US.UTF-8"
or export RUNEWIDTH_EASTASIAN=0
from lipgloss.
@meowgorithm
How to force terminal to run with this certain enviroment without configuring environment manually?
I tried
os.Setenv("RUNEWIDTH_EASTASIAN", "true")
os.Setenv("LC_CTYPE", "en_US.UTF-8")
before executing the main app, but that didn't work, any nice solution?
from lipgloss.
@Qrnbth have you tried os.Setenv("RUNEWIDTH_EASTASIAN", "0")
?
from lipgloss.
@meowgorithm How to force terminal to run with this certain enviroment without configuring environment manually? I tried
os.Setenv("RUNEWIDTH_EASTASIAN", "true") os.Setenv("LC_CTYPE", "en_US.UTF-8")before executing the main app, but that didn't work, any nice solution?
In the source code of
github.com/mattn/go-runewidth
, it obtains theRUNEWIDTH_EASTASIAN
environment variable using theinit()
function.According to the execution order of
init()
in Golang, you can create a separateconf
package in your project, and set theRUNEWIDTH_EASTASIAN
environment variable in theinit()
function within this package. Then, you can import theconf
package in themain
package.Just ensure that the
conf
package is the first in the import list of the main package, and it will take effect.package conf import ( "os" ) func init() { os.Setenv("RUNEWIDTH_EASTASIAN", "0") }package main import ( _ "project/conf" "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/glamour" "github.com/charmbracelet/lipgloss" )
This do works,thanks
from lipgloss.
Related Issues (20)
- Setting `BorderTop(false)` disappears entire border HOT 3
- Unexpected artifacts from lg.JoinVertical
- Renderer-level style rules
- Middle string truncation
- Background style is not rendered when wrapping other rendered styles HOT 4
- TopRight and BottomRight border not showing when rendering an empty string and no left border HOT 1
- OSC 8 (hyperlink) supports. HOT 1
- String transform method
- style.go::Render at 'Render core text' is not ansi aware when using a spaced styler HOT 1
- Text alignment logic is backwards for non-special-cases
- Overlap views HOT 2
- Unable to add right margin to an empty string HOT 3
- "nonspacing mark" unicode causes container's width to shift HOT 2
- Table without border and header truncates last line
- checksum mismatch HOT 3
- Table: truncation breaks ANSI styling HOT 3
- WithProfile not respected in custom rendered
- `Style.GetFrameSize()` does not account for border when using only `BorderStyle()` HOT 2
- Last line is misaligned if element aligned horizontally with set width
- Weird behaviour when using lipgloss in a test HOT 2
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 lipgloss.