-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
"Notification" encoding does not work for Windows in non-UTF8 systems #1191
Comments
Can you report whether this is fixed or not by adding the following line at thje top of the 'ps1' file? I got this hint from: https://stackoverflow.com/questions/49476326/displaying-unicode-in-powershell |
thank you for replay fyne--notify-1.ps1 $OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
$title = "Fyneの練習"
$content = "通知のテスト"
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02)
$toastXml = [xml] $template.GetXml()
$toastXml.GetElementsByTagName("text")[0].AppendChild($toastXml.CreateTextNode($title)) > $null
$toastXml.GetElementsByTagName("text")[1].AppendChild($toastXml.CreateTextNode($content)) > $null
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml($toastXml.OuterXml)
$toast = [Windows.UI.Notifications.ToastNotification]::new($xml)
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("appID").Show($toast); did not work as expected.
|
this worked fyne--notify-1.ps1 $title = "Fyneの練習"
$content = "通知のテスト"
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02)
$toastXml = [xml] $template.GetXml()
$toastXml.GetElementsByTagName("text")[0].AppendChild($toastXml.CreateTextNode($title)) > $null
$toastXml.GetElementsByTagName("text")[1].AppendChild($toastXml.CreateTextNode($content)) > $null
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml($toastXml.OuterXml)
$toast = [Windows.UI.Notifications.ToastNotification]::new($xml)
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("appID").Show($toast);
|
execution fails if the script file contain utf8 string. this worked const notificationTemplate = `Param( $title, $content )
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02)
$toastXml = [xml] $template.GetXml()
$toastXml.GetElementsByTagName("text")[0].AppendChild($toastXml.CreateTextNode($title)) > $null
$toastXml.GetElementsByTagName("text")[1].AppendChild($toastXml.CreateTextNode($content)) > $null
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml($toastXml.OuterXml)
$toast = [Windows.UI.Notifications.ToastNotification]::new($xml)
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("appID").Show($toast);`
script := notificationTemplate
err := ioutil.WriteFile(tmpFilePath, []byte(script), 0600)
if err != nil {
log.Println(err)
return
}
defer os.Remove(tmpFilePath)
title := "Fyneの練習"
content := "通知のテスト"
cmd := exec.Command("PowerShell", "-ExecutionPolicy", "Bypass", "-File", tmpFilePath, "-title", title, "-content", content)
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
out, err := cmd.CombinedOutput()
if err != nil {
log.Println(string(out), err)
} please confirm. |
Go uses UTF8 for everything, Windows does not! Fixes #1191
Many thanks for the hints. I had to use '-Raw' mode to avoid some errors in the processing but your suggestion was the key :) Now on |
Describe the bug:
notification don't work if they contain multi byte strings.
default encoding for power shell on japanese windows is SJIS.
UTF8 used in ps1 file.
To Reproduce:
Steps to reproduce the behaviour:
fyne.CurrentApp().SendNotification(fyne.NewNotification(title, content))
Example code:
generated script(utf8)
log
Device
The text was updated successfully, but these errors were encountered: