summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--op.c2
-rw-r--r--toke.c11
-rw-r--r--utf8.h9
3 files changed, 17 insertions, 5 deletions
diff --git a/op.c b/op.c
index f52ea291d3..677fe7a231 100644
--- a/op.c
+++ b/op.c
@@ -115,7 +115,7 @@ Perl_pad_allocmy(pTHX_ char *name)
if (!(PL_in_my == KEY_our ||
isALPHA(name[1]) ||
- (PL_hints & HINT_UTF8 && UTF8_IS_START(name[1])) ||
+ (USE_UTF8_IN_NAMES && UTF8_IS_START(name[1])) ||
(name[1] == '_' && (int)strlen(name) > 2)))
{
if (!isPRINT(name[1]) || strchr("\t\n\r\f", name[1])) {
diff --git a/toke.c b/toke.c
index d535442fd9..52706a324d 100644
--- a/toke.c
+++ b/toke.c
@@ -36,11 +36,14 @@ static I32 utf16rev_textfilter(pTHXo_ int idx, SV *sv, int maxlen);
#define XFAKEBRACK 128
#define XENUMMASK 127
-#ifdef EBCDIC
-/* For now 'use utf8' does not affect tokenizer on EBCDIC */
-#define UTF (PL_linestr && DO_UTF8(PL_linestr))
+#ifdef USE_UTF8_SCRIPTS
+# define UTF (!IN_BYTES)
#else
-#define UTF ((PL_linestr && DO_UTF8(PL_linestr)) || (PL_hints & HINT_UTF8))
+# ifdef EBCDIC /* For now 'use utf8' does not affect tokenizer on EBCDIC */
+# define UTF (PL_linestr && DO_UTF8(PL_linestr))
+# else
+# define UTF ((PL_linestr && DO_UTF8(PL_linestr)) || (PL_hints & HINT_UTF8))
+# endif
#endif
/* In variables named $^X, these are the legal values for X.
diff --git a/utf8.h b/utf8.h
index b793db612e..c475d0f287 100644
--- a/utf8.h
+++ b/utf8.h
@@ -7,6 +7,15 @@
*
*/
+/* Use UTF-8 as the default script encoding?
+ * Turning this on will break scripts having non-UTF8 binary
+ * data (such as Latin-1) in string literals. */
+#ifdef USE_UTF8_SCRIPTS
+# define USE_UTF8_IN_NAMES (!IN_BYTES)
+#else
+# define USE_UTF8_IN_NAMES (PL_hints & HINT_UTF8)
+#endif
+
#ifdef EBCDIC
/* The equivalent of these macros but implementing UTF-EBCDIC
are in the following header file: