aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorEli Zaretskii2013-10-26 13:37:43 +0300
committerEli Zaretskii2013-10-26 13:37:43 +0300
commitc3e9160b8c375760d6bc53602caeed211e91389d (patch)
tree94322287584b1c8a245a78caca63df5b16461a68 /src/coding.c
parent03d58cca817e8a21414c84696387813687c75261 (diff)
downloademacs-c3e9160b8c375760d6bc53602caeed211e91389d.tar.gz
emacs-c3e9160b8c375760d6bc53602caeed211e91389d.zip
Finished conversion routines; w32-unicode-filenames exposed to Lisp.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/coding.c b/src/coding.c
index ac828a48683..69b01553e7f 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -9473,6 +9473,49 @@ code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system,
9473 return code_convert_string (string, coding_system, Qt, encodep, 0, 1); 9473 return code_convert_string (string, coding_system, Qt, encodep, 0, 1);
9474} 9474}
9475 9475
9476/* Encode or decode a file name, to or from a unibyte string suitable
9477 for passing to C library functions. */
9478Lisp_Object
9479decode_file_name (Lisp_Object fname)
9480{
9481#ifdef WINDOWSNT
9482 /* The w32 build pretends to use UTF-8 for file-name encoding, and
9483 converts the file names either to UTF-16LE or to the system ANSI
9484 codepage internally, depending on the underlying OS; see w32.c. */
9485 if (! NILP (Fcoding_system_p (Qutf_8)))
9486 return code_convert_string_norecord (fname, Qutf_8, 0);
9487 return fname;
9488#else /* !WINDOWSNT */
9489 if (! NILP (Vfile_name_coding_system))
9490 return code_convert_string_norecord (fname, Vfile_name_coding_system, 0);
9491 else if (! NILP (Vdefault_file_name_coding_system))
9492 return code_convert_string_norecord (fname,
9493 Vdefault_file_name_coding_system, 0);
9494 else
9495 return fname;
9496#endif
9497}
9498
9499Lisp_Object
9500encode_file_name (Lisp_Object fname)
9501{
9502#ifdef WINDOWSNT
9503 /* The w32 build pretends to use UTF-8 for file-name encoding, and
9504 converts the file names either to UTF-16LE or to the system ANSI
9505 codepage internally, depending on the underlying OS; see w32.c. */
9506 if (! NILP (Fcoding_system_p (Qutf_8)))
9507 return code_convert_string_norecord (fname, Qutf_8, 1);
9508 return fname;
9509#else /* !WINDOWSNT */
9510 if (! NILP (Vfile_name_coding_system))
9511 return code_convert_string_norecord (fname, Vfile_name_coding_system, 1);
9512 else if (! NILP (Vdefault_file_name_coding_system))
9513 return code_convert_string_norecord (fname,
9514 Vdefault_file_name_coding_system, 1);
9515 else
9516 return fname;
9517#endif
9518}
9476 9519
9477DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, 9520DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string,
9478 2, 4, 0, 9521 2, 4, 0,