Skip to main content
added 158 characters in body
Source Link
julp
  • 111
  • 2

The only thing AddDefaultCharset does is to add charset=utf-8 to the HTTP header Content-type if the previous part is missing. Nothing to see with uploads or downloads.

On a Windows system, PHP functions relative to file system do not handle UTF-8 but ANSI code page (CP1252 for French) as PHP use ANSI functions and not Unicode functions (UTF-16) of Windows API.

IMO, in general, the best way to handle uploads is to generate unique file names and ignore client file names or, at least, ignore bytes > 0x7F.

$filename = filter_var($_FILES['upload']['name'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);

Can it be possible to check whether the current locale supports for utf-8 just before iconv() statement?

You can use setlocale (to get current locale FALSE !== strpos(setlocale(LC_CTYPE, '0'), 'UTF-8') and/or returns FALSE if it is unavaible if (!setlocale(LC_CTYPE, 'fr_FR.UTF-8'))).

UPDATE: as of PHP 7.1.0, PHP can now use UTF-8 encoded paths on Windows (set internal_encoding to UTF-8, for example - should be the case by default).

The only thing AddDefaultCharset does is to add charset=utf-8 to the HTTP header Content-type if the previous part is missing. Nothing to see with uploads or downloads.

On a Windows system, PHP functions relative to file system do not handle UTF-8 but ANSI code page (CP1252 for French) as PHP use ANSI functions and not Unicode functions (UTF-16) of Windows API.

IMO, in general, the best way to handle uploads is to generate unique file names and ignore client file names or, at least, ignore bytes > 0x7F.

$filename = filter_var($_FILES['upload']['name'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);

Can it be possible to check whether the current locale supports for utf-8 just before iconv() statement?

You can use setlocale (to get current locale FALSE !== strpos(setlocale(LC_CTYPE, '0'), 'UTF-8') and/or returns FALSE if it is unavaible if (!setlocale(LC_CTYPE, 'fr_FR.UTF-8'))).

The only thing AddDefaultCharset does is to add charset=utf-8 to the HTTP header Content-type if the previous part is missing. Nothing to see with uploads or downloads.

On a Windows system, PHP functions relative to file system do not handle UTF-8 but ANSI code page (CP1252 for French) as PHP use ANSI functions and not Unicode functions (UTF-16) of Windows API.

IMO, in general, the best way to handle uploads is to generate unique file names and ignore client file names or, at least, ignore bytes > 0x7F.

$filename = filter_var($_FILES['upload']['name'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);

Can it be possible to check whether the current locale supports for utf-8 just before iconv() statement?

You can use setlocale (to get current locale FALSE !== strpos(setlocale(LC_CTYPE, '0'), 'UTF-8') and/or returns FALSE if it is unavaible if (!setlocale(LC_CTYPE, 'fr_FR.UTF-8'))).

UPDATE: as of PHP 7.1.0, PHP can now use UTF-8 encoded paths on Windows (set internal_encoding to UTF-8, for example - should be the case by default).

formating
Source Link
Elin Y.
  • 7.4k
  • 1
  • 41
  • 65

The only thing AddDefaultCharsetAddDefaultCharset does is to add charset=utf-8charset=utf-8 to the HTTP header Content-type if the previous part is missing. Nothing to see with uploads or downloads.

On a Windows system, PHP functions relative to filesystemfile system do not handle UTF-8 but ANSI code page (CP1252 for French) as PHP use ANSI functions and not Unicode functions (UTF-16) of Windows API.

IMO, in general, the best way to handle uploads is to generate unique filenamesfile names and ignore client filenamesfile names or, at least, ignore bytes > 0x7F ($filename = filter_var($_FILES['upload']['name'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);0x7F).

$filename = filter_var($_FILES['upload']['name'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);

Can it be possible to check whether the current locale supports for utf-8 just before iconv() statement?

You can use setlocale setlocale (to get current locale FALSE !== strpos(setlocale(LC_CTYPE, '0'), 'UTF-8') and/or returns FALSEFALSE if it is unavaible if (!setlocale(LC_CTYPE, 'fr_FR.UTF-8'))).

The only thing AddDefaultCharset does is to add charset=utf-8 to the HTTP header Content-type if the previous part is missing. Nothing to see with uploads or downloads.

On Windows system, PHP functions relative to filesystem do not handle UTF-8 but ANSI code page (CP1252 for French) as PHP use ANSI functions and not Unicode functions (UTF-16) of Windows API.

IMO, in general, the best way to handle uploads is to generate unique filenames and ignore client filenames or, at least, ignore bytes > 0x7F ($filename = filter_var($_FILES['upload']['name'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);).

Can it be possible to check whether the current locale supports for utf-8 just before iconv() statement?

You can use setlocale (to get current locale FALSE !== strpos(setlocale(LC_CTYPE, '0'), 'UTF-8') and/or returns FALSE if it is unavaible if(!setlocale(LC_CTYPE, 'fr_FR.UTF-8'))).

The only thing AddDefaultCharset does is to add charset=utf-8 to the HTTP header Content-type if the previous part is missing. Nothing to see with uploads or downloads.

On a Windows system, PHP functions relative to file system do not handle UTF-8 but ANSI code page (CP1252 for French) as PHP use ANSI functions and not Unicode functions (UTF-16) of Windows API.

IMO, in general, the best way to handle uploads is to generate unique file names and ignore client file names or, at least, ignore bytes > 0x7F.

$filename = filter_var($_FILES['upload']['name'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);

Can it be possible to check whether the current locale supports for utf-8 just before iconv() statement?

You can use setlocale (to get current locale FALSE !== strpos(setlocale(LC_CTYPE, '0'), 'UTF-8') and/or returns FALSE if it is unavaible if (!setlocale(LC_CTYPE, 'fr_FR.UTF-8'))).

added 297 characters in body
Source Link
julp
  • 111
  • 2

The only thing AddDefaultCharset does is to add charset=utf-8 to the HTTP header Content-type if the previous part is missing. Nothing to see with uploads or downloads.

On Windows system, PHP functions relative to filesystem do not handle UTF-8 but ANSI code page (CP1252 for French) as PHP use ANSI functions and not Unicode functions (UTF-16) of Windows API.

IMYIMO, in general, the best way to handle uploads is to generate unique filenames and ignore client filenames or, at least, ignore bytes > 0x7F ($filename = filter_var($_FILES['upload']['name'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);).

Can it be possible to check whether the current locale supports for utf-8 just before iconv() statement?

You can use setlocale (to get current locale FALSE !== strpos(setlocale(LC_CTYPE, '0'), 'UTF-8') and/or returns FALSE if it is unavaible if(!setlocale(LC_CTYPE, 'fr_FR.UTF-8'))).

The only thing AddDefaultCharset does is to add charset=utf-8 to the HTTP header Content-type if the previous part is missing. Nothing to see with uploads or downloads.

On Windows system, PHP functions relative to filesystem do not handle UTF-8 but ANSI code page (CP1252 for French) as PHP use ANSI functions and not Unicode functions (UTF-16) of Windows API.

IMY, in general, the best way to handle uploads is to generate unique filenames and ignore client filenames or, at least, ignore bytes > 0x7F ($filename = filter_var($_FILES['upload']['name'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);).

The only thing AddDefaultCharset does is to add charset=utf-8 to the HTTP header Content-type if the previous part is missing. Nothing to see with uploads or downloads.

On Windows system, PHP functions relative to filesystem do not handle UTF-8 but ANSI code page (CP1252 for French) as PHP use ANSI functions and not Unicode functions (UTF-16) of Windows API.

IMO, in general, the best way to handle uploads is to generate unique filenames and ignore client filenames or, at least, ignore bytes > 0x7F ($filename = filter_var($_FILES['upload']['name'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);).

Can it be possible to check whether the current locale supports for utf-8 just before iconv() statement?

You can use setlocale (to get current locale FALSE !== strpos(setlocale(LC_CTYPE, '0'), 'UTF-8') and/or returns FALSE if it is unavaible if(!setlocale(LC_CTYPE, 'fr_FR.UTF-8'))).

Source Link
julp
  • 111
  • 2
Loading