Skip to content

Transforming unknown bytes #40

@lud-wj

Description

@lud-wj

I'm trying to encode invalid bytes as "#" like in the documentation example:

iso = Codepagex.from_string!("Hello æøå!", :iso_8859_1) <> <<1, 1, 1, 1>>

missing_fun =
  fn _encoding ->
    inner_fun =
      fn <<_, rest::binary>>, acc ->
        {:ok, "#", rest, acc}
      end

    {:ok, inner_fun}
  end

Codepagex.to_string(iso, :iso_8859_1, missing_fun)

But this returns the following:

{:ok, <<72, 101, 108, 108, 111, 32, 195, 166, 195, 184, 195, 165, 33, 1, 1, 1, 1>>, nil}

Is there a way to do what I want ?

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions