English 中文(简体)
Haskell 系统目录。 文件外观和非ASCII途径
原标题:Haskell System.Directory.doesFileExist and non-ASCII paths
import System.Directory
import qualified Data.ByteString as BS  
import qualified Data.ByteString.UTF8 as BS_UTF8

main = do
    putStrLn "Input path to some file: "
    raw_inputed_path <- BS.getLine
    let inputed_path = BS_UTF8.toString raw_inputed_path
    such_file_exists <- doesFileExist inputed_path
    such_directory_exists <- doesDirectoryExist inputed_path
    if such_file_exists 
        then putStrLn "Yeah, I see it!"
        else if such_directory_exists
            then putStrLn "Aha, I see it, but it s a directory!"
            else putStrLn "Hmm... No such..."

该法典只与ASCII-paths合作。 但是,如果我使用带有非ASCII符号的路径,doesFileExist doesDirectoryExist 总是<代码>False。 为什么?

  • Debian GNU/Linux 6.0 x86_64
  • ghc 6.12.1
最佳回答

升至7.x系列——现在有6.12位已经接近3年。 这种行为在一年前就确定。

问题回答

暂无回答




相关问题
Why are there duplicate characters in Unicode?

I can see some duplicate characters in Unicode. For example, the character C can be represented by the code points U+0043 and U+0421. Why is this so?

how to extract characters from a Korean string in VBA

Need to extract the initial character from a Korean word in MS-Excel and MS-Access. When I use Left("한글",1) it will return the first syllable i.e 한, what I need is the initial character i.e ㅎ . Is ...

File open error by using codec utf-8 in python

I execute following code on windows xp and python 2.6.4 But it show IOError. How to open file whose name has utf-8 codec. >>> open( unicode( 한글.txt , euc-kr ).encode( utf-8 ) ) Traceback ...

UnicodeEncodeError on MySQL insert in Python

I used lxml to parse some web page as below: >>> doc = lxml.html.fromstring(htmldata) >>> element in doc.cssselect(sometag)[0] >>> text = element.text_content() >>>...

Fast way to filter illegal xml unicode chars in python?

The XML specification lists a bunch of Unicode characters that are either illegal or "discouraged". Given a string, how can I remove all illegal characters from it? I came up with the following ...

热门标签