Skip to content

Detect UTF-16 BOM in CSV/TSV/JSONEachRow input and process it accordingly. #6476

Open

Description

@alexey-milovidov
No description provided.

Activity

  1. added
    easy task
    minor
    on Aug 13, 2019
  2. deleted a comment from stale on Jan 14, 2020
  3. alexey-milovidov commented on May 1, 2022

    @alexey-milovidov
    MemberAuthor

    It can be solved in generic way.

    Make UTFConvertingReadBuffer that will work as a wrapper on top of another ReadBuffer and it will check for these types of BOMs:

    • UTF-8 BOM
    • UTF-16 LE BOM
    • UTF-16 BE BOM
    • UTF-32 LE BOM
    • UTF-32 BE BOM

    If UTF-8 BOM is found, it will be ignored (and this can replace the existing logic of ignoring the UTF-8 BOM in TSV, CSV, etc),
    and the UTFConvertingReadBuffer will provide the remaining data in zero-copy fashion.

    If other BOM is found, we will use it to detect the charset and convert it on the fly to UTF-8.
    Care should be taken for correct processing of surrogate pairs.

    It's ok to convert invalid sequences to � or to another implementation-defined invalid sequence.
    The conversion should be performed without excessive buffering.

  4. mrdimidium commented on Jun 24, 2024

    @mrdimidium
    Contributor

    Hi, @alexey-milovidov! Is it still relevant? I'd like to try it.

  5. alexey-milovidov commented on Jun 24, 2024

    @alexey-milovidov
    MemberAuthor

    @nikolay-govorov, yes, it is relevant, and it will be very appreciated!

  6. chrisgoddard commented on Feb 6, 2025

    @chrisgoddard

    Any update on this?

  7. alexey-milovidov commented on Feb 6, 2025

    @alexey-milovidov
    MemberAuthor

    @chrisgoddard, no update on this - no one took this task.

  8. hp77-creator commented on Oct 23, 2025

    @hp77-creator
    Contributor

    Hi @alexey-milovidov, I am picking this one, will try to share a PR before end of month

  9. alexey-milovidov commented on Oct 23, 2025

    @alexey-milovidov
    MemberAuthor

    @hp77-creator, thank you for this!

  10. StashOfCode commented on May 15, 2026

    @StashOfCode

    @hp77-creator, @alexey-milovidov how is it going? csv file in a gcs bucket is interpreted as garbage by clickhouse:

    [22000] Code: 117. DB::Exception: Unknown field found in format header: '��D�a�t�e�' at position 0 Set the 'input_format_skip_unknown_fields' parameter explicitly to ignore and proceed: (while reading header):

    when 'ContentType': 'text/csv; charset=utf-16le',

  11. hp77-creator commented on May 15, 2026

    @hp77-creator
    Contributor

    I did something but that didn't work the way I thought it to work. I was supposed to close this but other commitments took priority and in recent times my system kind of gave up while doing dev for CH so I am blocked. If you want you can build upon my draft PR.

  12. StashOfCode commented on May 15, 2026

    @StashOfCode

    @hp77-creator thanks for the effort, regardless. My c++ skills are nonexistent otherwise, I would have tried.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

easy taskfeatureminor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions