Korean Filename Encoding Issue in CDR lastdata Field

Environment:

  • FreePBX 16
  • Asterisk 16
  • MariaDB (asteriskcdrdb database)

Problem Description

I’m encountering a character encoding issue with CDR records when using Korean filenames in audio playback.

What I’m doing:

java

originateAction.setData("silence/" + MUTE_TIME + "&" + soundFileName);

Where soundFileName contains Korean characters (한글). Asterisk successfully locates and plays the audio file without any issues.

The Problem: The issue occurs in the CDR logging. In the MariaDB asteriskcdrdb database, specifically in the cdr table, the lastdata field is storing corrupted Korean characters. Upon investigation, it appears the data is being stored using ISO_8859_1 encoding instead of UTF-8.

Current Workaround: I can retrieve the original Korean text using this Java code:

if (encoded.contains("á") || encoded.contains("¡") || encoded.contains("¨")) {
    try {
        byte[] rawBytes = encoded.getBytes(StandardCharsets.ISO_8859_1);
        return new String(rawBytes, StandardCharsets.UTF_8);
    } catch (Exception e) {
        return encoded;
    }
}

This successfully converts the corrupted text back to readable Korean characters.

Questions

  1. Why is this encoding mismatch happening? Asterisk can properly handle the Korean filename for audio playback, but the CDR system seems to be using a different character encoding.
  2. What’s the proper way to fix this at the source? Rather than post-processing the CDR data, I’d prefer to configure the system to handle UTF-8 Korean characters correctly from the start.
  3. Are there specific FreePBX/Asterisk configuration settings I should check for character encoding, particularly for CDR logging?
  4. Has anyone else encountered similar issues with non-ASCII filenames in CDR records?

Any guidance on resolving this encoding issue would be greatly appreciated. The current workaround functions but feels like a band-aid solution rather than addressing the root cause.

Thank you for your time and assistance!