Skip to content

copyFile and findExecutable don't work correctly if filename has national symbols

copyFile works doesn't work if first argument's filename has national symbols.

import System.Directory

main = do
    copyFile "test.txt" "テスト.txt" -- works
    print "copyFile works if second argument has national path."

    copyFile "テスト.txt" "test2.txt" -- doesn't work
    print "copyFile doesn't work if second argument has national path."

    copyFile "テスト.txt" "テスト2.txt" -- doesn't work
    print "copyFile doesn't work if first argument has national path."
C:\home>runghc.exe Test.hs
"copyFile works if second argument has national path."
Test.hs: ニケネ.txt: copyFile: does not exist (No such file or directory)

System.Win32.copyFile doesn't cause this problem.

import System.Win32

main = do
    copyFile "test.txt" "テスト.txt" False -- works
    print "copyFile works if second argument has national path."

    copyFile "テスト.txt" "test2.txt" False -- doesn't work
    print "copyFile doesn't work if second argument has national path."

    copyFile "テスト.txt" "テスト2.txt" False -- doesn't work
    print "copyFile doesn't work if first argument has national path."
C:\home>runghc.exe Test.hs
"copyFile works if second argument has national path."
"copyFile doesn't work if second argument has national path."
"copyFile doesn't work if first argument has national path."

And findExecutable return Nothing if executable file name has national symbols.

import System.Directory -- hiding (getDirectoryContents)

main = findExecutable "テスト" >>= print
C:\home>runghc.exe Test.hs
Nothing

So, I made patch for these two problems.

Trac metadata
Trac field Value
Version 6.10.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/directory
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information