# man > encoding::warnings

yaml
---
type: CommandReference
command: encoding::warnings
mode: perldoc
section: 3perl
source: perldoc
---
## Quick Reference

- `use encoding::warnings;` — enable warnings on implicit byte-string to unicode-string upgrades
- `use encoding::warnings 'FATAL';` — make such warnings fatal
- `$c = $a . $b;` — triggers warning if `$a` is a byte-string with high-bit bytes and `$b` is a unicode-string
- `use encoding 'utf8';` — specify encoding to silence warnings (also affects literals and IO)
- `use encoding 'iso-8859-1';` — preserve default behavior, silence warnings
- `use utf8::encode($str);` — downgrade a unicode-string to byte-string (UTF-8 encoded)
- `use Encode::encode('UTF-8', $str);` — explicit encoding conversion
- **Deprecated** — as of Perl 5.26.0, this module has no effect; loading it produces a single warning.

## Name

**encoding::warnings** — warn on implicit encoding conversions (byte-string to unicode-string)

## Synopsis

perl
use encoding::warnings;          # or 'FATAL' to raise fatal exceptions

utf8::encode($a = chr(20000));   # byte-string (raw bytes)
$b = chr(20000);                 # unicode-string (wide characters)

# "Bytes implicitly upgraded into wide characters as iso-8859-1"
$c = $a . $b;
## Description

### Overview

Perl silently upgrades byte-strings (raw bytes) to unicode-strings assuming ISO 8859-1 (Latin-1) encoding. This can cause problems when mixing unicode strings with non-Latin1 data (e.g., UTF-8 bytes). The error only manifests on output, making diagnosis difficult.

### Detection

Add `use encoding::warnings;` to the top of your main program. Implicit upgrading of high-bit bytes (0x80–0xFF) will then produce a warning:

> Bytes implicitly upgraded into wide characters as iso-8859-1 at - line 7

Pure ASCII (0x00–0x7F) strings do not trigger the warning.

Use `use encoding::warnings 'FATAL';` to make warnings fatal.

### Solutions

- **Upgrade both sides to unicode-strings** — apply appropriate IO disciplines (see `open`, `binmode` in perlfunc).
- **Downgrade both sides to byte-strings** — use `Encode::encode()` or `utf8::encode()`.
- **Specify encoding for implicit upgrading** — `use encoding 'utf8';` or `use encoding 'iso-8859-1';` silences warnings but also affects literals and IO. The `Filter => 1` flavor does **not** silence warnings.

### Caveats

- Perl 5.9.4+: effect is lexical.
- Perl < 5.9.4: affects the whole script.
- **Deprecated** — as of Perl 5.26.0, the internal feature this module used has been removed; loading the module gives one warning and does nothing else.

## Examples

perl
# Enable warnings
use encoding::warnings;

# Example: concatenation that triggers warning
utf8::encode($a = chr(20000));   # byte-string
$b = chr(20000);                 # unicode-string
$c = $a . $b;                    # warning: bytes implicitly upgraded

# Silence warnings by specifying encoding
use encoding 'utf8';
$c = $a . $b;                    # no warning, but $a now treated as UTF-8 bytes

# Explicit downgrade
use utf8;
$b = chr(20000);
$d = utf8::encode($b);           # downgrade to byte-string
## See Also

- [perlunicode](http://localhost/phpMan.php/perldoc/perlunicode/markdown)
- [perluniintro](http://localhost/phpMan.php/perldoc/perluniintro/markdown)
- [open](http://localhost/phpMan.php/perldoc/open/markdown)
- [utf8](http://localhost/phpMan.php/perldoc/utf8/markdown)
- [encoding](http://localhost/phpMan.php/perldoc/encoding/markdown)
- [Encode](http://localhost/phpMan.php/perldoc/Encode/markdown)