unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* filename(CJK utf8) problem on OSX.
@ 2016-03-28  1:21 Park SungMin
  2016-03-28  4:59 ` Alex Vong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Park SungMin @ 2016-03-28  1:21 UTC (permalink / raw
  To: guile-user

follow code….. I just test openfile(CJK filename).
"open-file" and "call-with-input-file" are raise error.  so I test use low C(Posix) API, then run ok!
I don’t know is it bug? or option problem?
 

(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/사진.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 (= 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….
(file-exists? filename) ;; #f
(open-file filename "r") ; ERROR: In procedure open-file: No such file or directory: "/Users/byul/Desktop/사진.gif"











^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: filename(CJK utf8) problem on OSX.
  2016-03-28  1:21 filename(CJK utf8) problem on OSX Park SungMin
@ 2016-03-28  4:59 ` Alex Vong
  2016-03-28  5:35 ` tomas
  2016-03-28 15:07 ` Eli Zaretskii
  2 siblings, 0 replies; 4+ messages in thread
From: Alex Vong @ 2016-03-28  4:59 UTC (permalink / raw
  To: Park SungMin; +Cc: guile-user

Park SungMin <byulparan_eng@icloud.com> writes:

> follow code….. I just test openfile(CJK filename).
> "open-file" and "call-with-input-file" are raise error.  so I test use low C(Posix) API, then run ok!
> I don’t know is it bug? or option problem?
>  
>
> (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/사진.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 (= 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….
> (file-exists? filename) ;; #f
> (open-file filename "r") ; ERROR: In procedure open-file: No such file or directory: "/Users/byul/Desktop/사진.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/사진.gif")
(system* "touch" filename) ;; create the file if not exist
;;; $1 = 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 (= fd -1)
	(throw 'can't-find-file))
      (fdes->inport fd))))

(define port (my-open-file filename))

(get-bytevector-n port 10)
;;; $2 = #<eof>

(file-exists? filename)
;;; $3 = #t

(open-file filename "r")
;;; $4 = #<input: /home/alexvong1995/사진.gif 10>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: filename(CJK utf8) problem on OSX.
  2016-03-28  1:21 filename(CJK utf8) problem on OSX Park SungMin
  2016-03-28  4:59 ` Alex Vong
@ 2016-03-28  5:35 ` tomas
  2016-03-28 15:07 ` Eli Zaretskii
  2 siblings, 0 replies; 4+ messages in thread
From: tomas @ 2016-03-28  5:35 UTC (permalink / raw
  To: guile-user

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, Mar 28, 2016 at 10:21:46AM +0900, Park SungMin wrote:
> follow code….. I just test openfile(CJK filename).
> "open-file" and "call-with-input-file" are raise error.  so I test use low C(Posix) API, then run ok!
> I don’t know is it bug? or option problem? 

[...]

> ;;but….
> (file-exists? filename) ;; #f
> (open-file filename "r") ; ERROR: In procedure open-file: No such file or directory: "/Users/byul/Desktop/사진.gif"

I think the port encoding has nothing to do with the encoding
of the file name. It is effective only once you've opened the
file (i.e. for the file content). For the file name, I'd say
your current locale is the relevant thing; start here:

  https://www.gnu.org/software/guile/manual/html_node/Locales.html

regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlb4wrUACgkQBcgs9XrR2kZQLACbBVv12GD1IbReUY/cks1gavv5
lAMAni15UHKElYjKhSkimM48fMum27QN
=bfF7
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: filename(CJK utf8) problem on OSX.
  2016-03-28  1:21 filename(CJK utf8) problem on OSX Park SungMin
  2016-03-28  4:59 ` Alex Vong
  2016-03-28  5:35 ` tomas
@ 2016-03-28 15:07 ` Eli Zaretskii
  2 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2016-03-28 15:07 UTC (permalink / raw
  To: Park SungMin; +Cc: guile-user

> From: Park SungMin <byulparan_eng@icloud.com>
> Date: Mon, 28 Mar 2016 10:21:46 +0900
> 
> (define filename "/Users/byul/Desktop/사진.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 (= 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….
> (file-exists? filename) ;; #f
> (open-file filename "r") ; ERROR: In procedure open-file: No such file or directory: "/Users/byul/Desktop/사진.gif"

Isn't this because OS X filesystems store file names in decomposed
form?



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-03-28 15:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-28  1:21 filename(CJK utf8) problem on OSX Park SungMin
2016-03-28  4:59 ` Alex Vong
2016-03-28  5:35 ` tomas
2016-03-28 15:07 ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).