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

Japanese String Incorrectly Encoded #13093

Closed
GrandArth opened this issue Jul 4, 2020 · 2 comments
Closed

Japanese String Incorrectly Encoded #13093

GrandArth opened this issue Jul 4, 2020 · 2 comments
Labels
Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a

Comments

@GrandArth
Copy link

Steps to reproduce

  1. Install Mediainfo
  2. Find any track with Japanese Tag
Mediainfo 1-01.m4a
$text=Mediainfo 1-01.m4a
$text

Expected behavior

This is the output that directly showed in the native terminal for PS7 with Mediainfo 1-01.m4a

General
Complete name                            : 1-01.m4a
Format                                   : MPEG-4
Format profile                           : Apple audio with iTunes info
Codec ID                                 : M4A  (M4A /isom/iso2)
File size                                : 14.5 MiB
Duration                                 : 1 min 55 s
Overall bit rate mode                    : Variable
Overall bit rate                         : 1 053 kb/s
Album                                    : 「おねがい☆ツインズ」コンプリートサウンドトラック「Photograph」
Album/Sorted by                          : 「オネガイ☆ツインズ」コンプリートサウンドトラック「Photograph」
Album/Performer                          : I've
Album/Performer/Sort                     : Ive
Part/Position                            : 1
Part/Total                               : 2
Track name                               : Second Flight(TV Size)
Track name/Position                      : 1
Track name/Total                         : 32
Performer                                : KOTOKO / 佐藤裕美
Performer/Sorted by                      : KOTOKO & サトウヒロミ
Genre                                    : ゲーム音楽
Recorded date                            : 2005
Writing application                      : Lavf58.42.102
Cover                                    : Yes
Title/Sort                               : Second F light(TV Size)

Audio
ID                                       : 1
Format                                   : ALAC
Codec ID                                 : alac
Codec ID/Info                            : Apple Lossless Audio Codec
Duration                                 : 1 min 55 s
Duration_LastFrame                       : -62 ms
Bit rate mode                            : Variable
Bit rate                                 : 1 050 kb/s
Nominal bit rate                         : 1 411 kb/s
Channel(s)                               : 2 channels
Sampling rate                            : 44.1 kHz
Bit depth                                : 16 bits
Stream size                              : 14.5 MiB (100%)
Default                                  : Yes
Alternate group                          : 1

Actual behavior

This is what i got after storing the output into a variable (or redirect it to a file)

General
Complete name                            : 1-01.m4a
Format                                   : MPEG-4
Format profile                           : Apple audio with iTunes info
Codec ID                                 : M4A  (M4A /isom/iso2)
File size                                : 14.5 MiB
Duration                                 : 1 min 55 s
Overall bit rate mode                    : Variable
Overall bit rate                         : 1 053 kb/s
Album                                    : 銆屻亰銇亴銇勨 槅銉勩偆銉炽偤銆嶃偝銉炽儣銉兗銉堛偟銈︺兂銉夈儓銉┿儍銈€孭hotograph銆?
Album/Sorted by                          : 銆屻偑銉嶃偓銈も 槅銉勩偆銉炽偤銆嶃偝銉炽儣銉兗銉堛偟銈︺兂銉夈儓銉┿儍銈€孭hotograph銆?
Album/Performer                          : I've
Album/Performer/Sort                     : Ive
Part/Position                            : 1
Part/Total                               : 2
Track name                               : Second Flight锛圱V Size锛?
Track name/Position                      : 1
Track name/Total                         : 32
Performer                                : KOTOKO / 浣愯棨瑁曠編
Performer/Sorted by                      : KOTOKO & 銈点儓銈︺儝銉儫
Genre                                    : 銈层兗銉犻煶妤?
Recorded date                            : 2005
Writing application                      : Lavf58.42.102
Cover                                    : Yes
Title/Sort                               : 锛筹絽锝冿綇锝庯 絼銆€锛︼綄锝夛絿锝堬綌锛堬即锛躲€€锛筹綁锝氾絽锛?

Audio
ID                                       : 1
Format                                   : ALAC
Codec ID                                 : alac
Codec ID/Info                            : Apple Lossless Audio Codec
Duration                                 : 1 min 55 s
Duration_LastFrame                       : -62 ms
Bit rate mode                            : Variable
Bit rate                                 : 1 050 kb/s
Nominal bit rate                         : 1 411 kb/s
Channel(s)                               : 2 channels
Sampling rate                            : 44.1 kHz
Bit depth                                : 16 bits
Stream size                              : 14.5 MiB (100%)
Default                                  : Yes
Alternate group                          : 1

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.2
PSEdition                      Core
GitCommitId                    7.0.2
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
@GrandArth GrandArth added the Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a label Jul 4, 2020
@mklement0
Copy link
Contributor

mklement0 commented Jul 4, 2020

If the character encoding used by an external program doesn't match the encoding stored in [console]::OutputEncoding, PowerShell will misinterpret the program's output, if captured or redirected.

Assuming that MediaInfo outputs UTF-16LE-encoded text, run the following beforehand (and restore the original encoding afterwards, if needed):

[console]::OutputEncoding = [System.Text.UnicodeEncoding]::new()

Generally, [console]::OutputEncoding still defaults to the active OEM code page on Windows, unfortunately - see #7233; on Unix-like platforms, it is sensibly UTF-8.

@GrandArth
Copy link
Author

Thx this sloves the problem for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
Projects
None yet
Development

No branches or pull requests

2 participants