com doc/ja: Fix/clarify dirname/basename docs wrt. locales: reference/filesystem/functions/basename.xml reference/filesystem/functions/dirname.xml
| From: | Yoshinari Takaoka | Date: | Fri, 19 Feb 2021 20:12:42 +0000 |
| Subject: | com doc/ja: Fix/clarify dirname/basename docs wrt. locales: reference/filesystem/functions/basename.xml reference/filesystem/functions/dirname.xml | ||
| Groups: | php.doc.ja | ||
| Request: | Send a blank email to doc-ja+get-6208@lists.php.net to get a copy of this message | ||
Commit: be7a5ed14c6265033004e75ed9196f770aeada0c
Author: Yoshinari Takaoka <mumumu@mumumu.org> Sat, 20 Feb 2021 05:12:42 +0900
Parents: b127eb156f5dacb81ca88da9382cafd4fb968e33
Branches: master
Link: http://git.php.net/?p=doc/ja.git;a=commitdiff;h=be7a5ed14c6265033004e75ed9196f770aeada0c
Log:
Fix/clarify dirname/basename docs wrt. locales
For basename(), we declare the behavior regarding invalid characters in
the path as being undefined, since that depends on the availability of
mblen, and also on the position of the invalid characters prior to PHP
8.0.0[1].
dirname() is actually not local-aware, but relies on an ASCII
compatible character encoding regarding the directory separator. On
Windows, it is however, dependent on the currently set codepage
(although a fallback is still in place to use the Windows ANSI codepage
of the operating system[2], if the string is not valid for the current
codepage).
Again, we declared failure to comply to these assumptions as resulting
in undefined behavior. Users should make sure to pass valid strings.
[1] <http://git.php.net/?p=php-src.git;a=commitdiff;h=90705d44e3da1d0aa7b8b4fd921ec597391eccb2>
[2] <https://github.com/php/php-src/blob/5e015425263c28d40fd49ee386135f02d0e76975/win32/codepage.h#L95-L106>
Changed paths:
M reference/filesystem/functions/basename.xml
M reference/filesystem/functions/dirname.xml
Diff:
diff --git a/reference/filesystem/functions/basename.xml
b/reference/filesystem/functions/basename.xml
index c6ce024965..9633348eb3 100644
--- a/reference/filesystem/functions/basename.xml
+++ b/reference/filesystem/functions/basename.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
-<!-- EN-Revision: 0c9c2dd669fe9395eaa73d487fbd160f9057429a Maintainer: hirokawa Status: ready
-->
+<!-- EN-Revision: 88c1f8d6c9fecf352c5ce152a6f758ed013fc2c0 Maintainer: hirokawa Status: ready
-->
<!-- Credits: mumumu -->
<refentry xml:id="function.basename" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
@@ -31,6 +31,8 @@
<function>basename</function> はロケールに依存します。
マルチバイト文字を含むパスで正しい結果を得るには、それと一致するロケールを
<function>setlocale</function> で設定しておかなければなりません。
+ 現在のロケールから見て不正な文字が <parameter>path</parameter>
に含まれていた場合、
+ <function>basename</function> の動作は未定義です。
</para>
</caution>
</refsect1>
diff --git a/reference/filesystem/functions/dirname.xml b/reference/filesystem/functions/dirname.xml
index 0b8d2e9199..df9d0374bb 100644
--- a/reference/filesystem/functions/dirname.xml
+++ b/reference/filesystem/functions/dirname.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
-<!-- EN-Revision: af6fdf16ab44bcf4d045407963e43c3d9dd2ff29 Maintainer: hirokawa Status: ready
-->
+<!-- EN-Revision: 88c1f8d6c9fecf352c5ce152a6f758ed013fc2c0 Maintainer: hirokawa Status: ready
-->
<!-- CREDITS: shimooka,mumumu -->
<refentry xmlns="http://docbook.org/ns/docbook"
xml:id="function.dirname">
<refnamediv>
@@ -28,9 +28,17 @@
</note>
<caution>
<para>
- <function>dirname</function> はロケールに依存します。
-
マルチバイト文字を含むパスで正しい結果を得るには、それと一致するロケールを
- <function>setlocale</function> で設定しておかなければなりません。
+ Windows では、<function>dirname</function>
+ は現在設定されているコードページに依存します。
+ よって、マルチバイト文字が含まれたパスを正しく表示するには、
+ それと一致するコードページが設定されていなければいけません。
+ 現在のコードページから見て不正な文字が
<parameter>path</parameter> に含まれていた場合、
+ <function>basename</function> の動作は未定義です。
+ </para>
+ <para>
+ Windows 以外のシステムでは、
+ <parameter>path</parameter> はASCII
と互換性があるエンコーディングでエンコードされていると想定されています。
+ そうでない場合、この関数の動作は未定義です。
</para>
</caution>
</refsect1>