mirror of
https://github.com/php/php-src.git
synced 2024-09-22 18:37:25 +00:00
This makes file_put_contents() work for:
<?php declare(encoding="latin1"); $a = "1234å67890"; file_put_contents( "/tmp/testuc.1", $a); file_put_contents( "/tmp/testuc.2", (string) $a); $context = stream_context_create(); stream_context_set_params($context, array( "output_encoding" => "latin1" ) ); file_put_contents( "/tmp/testuc.3", $a, FILE_TEXT, $context); file_put_contents( "/tmp/testuc.4", (string) $a, FILE_TEXT, $context); ?> But it still throws a warning on ".3". It's a small design issue that I didn't want to touch right now.
This commit is contained in:
parent
fef63cd5e5
commit
f7bfe18307
@ -662,7 +662,7 @@ PHP_FUNCTION(file_put_contents)
|
||||
if (numchars < 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write %d characters to %s", ustrlen, filename);
|
||||
numchars = -1;
|
||||
} else if (numchars != UBYTES(Z_USTRLEN_P(data))) {
|
||||
} else if (numchars != ustrlen) {
|
||||
int numchars = u_countChar32(Z_USTRVAL_P(data), numchars);
|
||||
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %d of %d characters written, possibly out of free disk space", numchars, ustrlen);
|
||||
|
@ -1140,7 +1140,7 @@ static size_t _php_stream_write_buffer(php_stream *stream, int buf_type, zstr bu
|
||||
stream->ops->seek(stream, stream->position, SEEK_SET, &stream->position TSRMLS_CC);
|
||||
}
|
||||
|
||||
if (stream->output_encoding) {
|
||||
if (stream->output_encoding && buf_type == IS_UNICODE) {
|
||||
char *dest;
|
||||
int destlen;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
@ -1150,7 +1150,9 @@ static size_t _php_stream_write_buffer(php_stream *stream, int buf_type, zstr bu
|
||||
buflen = destlen;
|
||||
} else {
|
||||
/* Sloppy handling, make it a binary buffer */
|
||||
buflen = UBYTES(buflen);
|
||||
if (buf_type != IS_STRING) {
|
||||
buflen = UBYTES(buflen);
|
||||
}
|
||||
}
|
||||
|
||||
while (buflen > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user