From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alex Vong Newsgroups: gmane.lisp.guile.user Subject: Re: filename(CJK utf8) problem on OSX. Date: Mon, 28 Mar 2016 12:59:07 +0800 Message-ID: <874mbr5hb8.fsf@gmail.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1459141174 21748 80.91.229.3 (28 Mar 2016 04:59:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 28 Mar 2016 04:59:34 +0000 (UTC) Cc: guile-user@gnu.org To: Park SungMin Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Mar 28 06:59:28 2016 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1akPGx-0008Hg-Kl for guile-user@m.gmane.org; Mon, 28 Mar 2016 06:59:27 +0200 Original-Received: from localhost ([::1]:39223 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akPGw-0002mj-NQ for guile-user@m.gmane.org; Mon, 28 Mar 2016 00:59:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54959) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akPGn-0002lT-76 for guile-user@gnu.org; Mon, 28 Mar 2016 00:59:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1akPGi-00031z-7N for guile-user@gnu.org; Mon, 28 Mar 2016 00:59:17 -0400 Original-Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]:34222) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akPGh-00031v-WC for guile-user@gnu.org; Mon, 28 Mar 2016 00:59:12 -0400 Original-Received: by mail-pa0-x22a.google.com with SMTP id fe3so89603331pab.1 for ; Sun, 27 Mar 2016 21:59:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=gg3XmR+rIoEMwmmte7M6BvSje8Z+CrwuE7yFlo3K924=; b=qN6R/C0o3Lap38pqNgjSH8jFhToXN+hg5jWQqk9cXkY2yIdNeqy6w1WRl4ARlJt9GY rmUu5o/YE9ludNmxcqN7ZCZMvbf2iM4SQBLxHDJ3M8f91r50tGYCrOez/eJ1bHOkGOQ/ lNLa1xWDcHlTN3oHLyIeZqLlCjaooWB9ybub+DSur6WUri0Agn852HiW58ZWIG0Ww9dD 86gyZ8A6OorgomfioIG1eYcWipJHvR4P6dKAIQD9TCI8it4yoBEtiy/rXu6RlOUVj5gQ nnGJr77XbzweectN7m0c52lHqHqi8GzU2k+3jinjo57IZcjhP6wCiUSO9LBZm8e3hfIb j8+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=gg3XmR+rIoEMwmmte7M6BvSje8Z+CrwuE7yFlo3K924=; b=W5yuV80s5jrkVbSWXYloHwMFsgdGNwGKqutF9Y+fh/vBLp2rzQHQkK9Ad3WEEQEn3c jufI7V68ht4+Hm/gx3Eth0qLYGjofb6fUeZL4OPmnMZy+Gq9QH/iL3zpjpeUT3QWpsxj cYT8uaECykiItRszf4nFtxHDcvr37qkaLUFvBBjxQRsRo2d9bb64aYLk8k4BS+NUvXCv Q5+EzCZqvnSCfOdznWAgqjzT/HG9Py8M5WyVJRVcs2vfBhSDypfiFkSQwQZfqGw9Sz3d WOef7XbsILyYogkMz/zWKuTdfak2muZEjNAQ8o+9fvg1JD0ROcD0ZQHNS5hoW01WyHT+ j59g== X-Gm-Message-State: AD7BkJJMQynedqX8p6yhq7etygJ00eIC9LfhWpKU8B9NJ6Z5/3zvU5ACmpXQfcLuXiVFcg== X-Received: by 10.67.5.133 with SMTP id cm5mr39462984pad.133.1459141150951; Sun, 27 Mar 2016 21:59:10 -0700 (PDT) Original-Received: from debian (n058152177019.netvigator.com. [58.152.177.19]) by smtp.gmail.com with ESMTPSA id v14sm31917536pas.10.2016.03.27.21.59.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Mar 2016 21:59:10 -0700 (PDT) In-Reply-To: (Park SungMin's message of "Mon, 28 Mar 2016 10:21:46 +0900") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c03::22a X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:12501 Archived-At: Park SungMin writes: > follow code=E2=80=A6.. I just test openfile(CJK filename). > "open-file" and "call-with-input-file" are raise error. so I test use lo= w C(Posix) API, then run ok! > I don=E2=80=99t know is it bug? or option problem? >=20=20 > > (use-modules (rnrs io ports) > (rnrs bytevectors) > (system foreign) > (ice-9 rdelim)) > > (fluid-set! %default-port-encoding "utf-8") > (set-port-encoding! (current-output-port) "utf-8") > (set-port-encoding! (current-input-port) "utf-8") > > (define filename "/Users/byul/Desktop/=EC=82=AC=EC=A7=84.gif") > > (define my-open-file > (lambda (filename) > (let* ((fd ((pointer->procedure > int > (dynamic-func "open" (dynamic-link)) > (list '* int)) > (bytevector->pointer > (string->utf8 filename)) > O_RDONLY))) > (when (=3D fd -1) > (throw 'can't-find-file)) > (fdes->inport fd)))) > > (define port (my-open-file filename)) > > (get-bytevector-n port 10) ;; OK. I get bytevector. > > ;;but=E2=80=A6. > (file-exists? filename) ;; #f > (open-file filename "r") ; ERROR: In procedure open-file: No such file or= directory: "/Users/byul/Desktop/=EC=82=AC=EC=A7=84.gif" I cannot reproduce it on GNU/Linux. Perhaps others know what's going wrong. For now, you could try setting port encoding to "UTF-8" instead of "utf-8". Also, I remember OS X ships an ancient version of libiconv, maybe you can try installing the latest version. (use-modules (rnrs io ports) (rnrs bytevectors) (system foreign) (ice-9 rdelim)) (fluid-set! %default-port-encoding "utf-8") (set-port-encoding! (current-output-port) "utf-8") (set-port-encoding! (current-input-port) "utf-8") (define filename "/home/alexvong1995/=EC=82=AC=EC=A7=84.gif") (system* "touch" filename) ;; create the file if not exist ;;; $1 =3D 0 (define my-open-file (lambda (filename) (let* ((fd ((pointer->procedure int (dynamic-func "open" (dynamic-link)) (list '* int)) (bytevector->pointer (string->utf8 filename)) O_RDONLY))) (when (=3D fd -1) (throw 'can't-find-file)) (fdes->inport fd)))) (define port (my-open-file filename)) (get-bytevector-n port 10) ;;; $2 =3D # (file-exists? filename) ;;; $3 =3D #t (open-file filename "r") ;;; $4 =3D #