Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode support #153

Closed
ii64 opened this issue Nov 5, 2021 · 6 comments
Closed

Unicode support #153

ii64 opened this issue Nov 5, 2021 · 6 comments
Labels
question Further information is requested

Comments

@ii64
Copy link

ii64 commented Nov 5, 2021

Hello i tried to input unicode but it is not recognized by bubbletea, Thank you.
go version go1.17 windows/amd64

image

image
image

type tuiModel struct {
	p string
}
func (m *tuiModel) Init() tui.Cmd {
	return func() tui.Msg {
		return nil
	}
}
func (m *tuiModel) Update(msg tui.Msg) (tui.Model, tui.Cmd) {
	switch msg := msg.(type) {
	case tui.KeyMsg:
		return m.handleKeyboardInput(msg)
	}
	return m, nil
}
func (m *tuiModel) View() string {
	return m.p
}
func (m *tuiModel) handleKeyboardInput(msg tui.KeyMsg) (tui.Model, tui.Cmd) {
	switch msg.String() {
	case "ctrl+c":
		return m, tui.Quit
	}
	m.p = m.p + fmt.Sprintf("\n%s (%+#v)", msg, msg)
	return m, nil
}
@meowgorithm
Copy link
Member

meowgorithm commented Nov 5, 2021

Hi! Unicode and IME are supported supported by Bubble Tea. What's your system locale set to? Sometimes we've seen this happen when the locale isn’t UTF-8, particularly with CJK locales.

Also, the quick solution is often to set your system locale to UTF-8. On my English/US version of Windows 11 that’s: Control Panel -> Clock and Region -> Region -> Administrative Tab -> Change system locale… -> Beta: Use Unicode UTF-8 for worldwide language support.

@jon4hz
Copy link
Contributor

jon4hz commented Nov 8, 2021

I've run into issues using unicode symbols on windows (cmd & powershell but not windows terminal). I suppose both don't support the full char set by default. Is there a way to check, if the terminal supports certain chars?

@ii64
Copy link
Author

ii64 commented Nov 14, 2021

Okay i got Beta: Use Unicode UTF-8 for worldwide language support enabled, restarted my computer, but problem remain the same :/.

【我愛你】 converted to tea.KeyMsg{Type:-1, Runes:[]int32{0, 0, 0}, Alt:false}.

Edit: terminal used Microsoft Windows Terminal, Microsoft Pinyin.

image
image

@knz
Copy link
Contributor

knz commented Aug 25, 2022

I think this was fixed in #343. Can you check?

@buffos
Copy link

buffos commented Apr 30, 2024

I am having the same problem (when using huh). They are probably related.
There is no support for Greek characters in input fields. Utf-8 is enabled.

@meowgorithm
Copy link
Member

Hi! This is specific to Windows and should be fixed on master.

go get github.com/charmbracelet/bubbletea@master`

If that's not the case, please re-open the issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants