Skip to content

Commit 78d3af4

Browse files
committed
Make sure php_get_internal_encoding() returns non-empty
Even if default_charset is set to "", we should still return "UTF-8" as the default value here. Setting default_charset to "" suppresses the header emission, but shouldn't change anything about our encoding defaults.
1 parent 3ca08ee commit 78d3af4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

main/main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,28 +562,28 @@ static PHP_INI_DISP(display_errors_mode)
562562
PHPAPI const char *php_get_internal_encoding() {
563563
if (PG(internal_encoding) && PG(internal_encoding)[0]) {
564564
return PG(internal_encoding);
565-
} else if (SG(default_charset)) {
565+
} else if (SG(default_charset) && SG(default_charset)[0]) {
566566
return SG(default_charset);
567567
}
568-
return "";
568+
return "UTF-8";
569569
}
570570

571571
PHPAPI const char *php_get_input_encoding() {
572572
if (PG(input_encoding) && PG(input_encoding)[0]) {
573573
return PG(input_encoding);
574-
} else if (SG(default_charset)) {
574+
} else if (SG(default_charset) && SG(default_charset)[0]) {
575575
return SG(default_charset);
576576
}
577-
return "";
577+
return "UTF-8";
578578
}
579579

580580
PHPAPI const char *php_get_output_encoding() {
581581
if (PG(output_encoding) && PG(output_encoding)[0]) {
582582
return PG(output_encoding);
583-
} else if (SG(default_charset)) {
583+
} else if (SG(default_charset) && SG(default_charset)[0]) {
584584
return SG(default_charset);
585585
}
586-
return "";
586+
return "UTF-8";
587587
}
588588

589589
PHPAPI void (*php_internal_encoding_changed)(void) = NULL;

0 commit comments

Comments
 (0)