JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.21k stars 1.17k forks source link

Using Chinese characters in tray will generate garbled code #1936

Closed whitescent closed 1 month ago

whitescent commented 2 years ago
Tray(
    icon = AppIcon(),
    tooltip = "Kftp",
    onAction = { isVisible = true },
    menu = {
        Item("Exit", onClick = ::exitApplication)
    }
)

It shows well.

PNKUY TSA6Y3OVP1H$R 2GB

Tray(
    icon = AppIcon(),
    tooltip = "Kftp",
    onAction = { isVisible = true },
    menu = {
        Item("退出程序", onClick = ::exitApplication)
    }
)

image

info

compose: 1.1.0
os: windows 11

Update:

I found that if I run the program directly from IDEA, it shows garbled code, but if I run it as a jar or exe, it doesn't have this error.

image

Winterreisender commented 2 years ago

I met the same bug and I think it is a string encoding/decoding problem related to AWT. All AWT widgets seems not supporting UTF-8 by default. You can try to add -Dfile.encoding=gbk to jvmArgs to fix it, though it does not seems like a good solution.

Another way could be using a font support UTF8, see Unicode text is not displayed correctly in awt Label. Maybe a font parameter of MenuScope.Item is helpful.

okushnikov commented 3 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.