Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emojis get escaped when serializing #400

Open
ahartwel opened this issue Aug 17, 2023 · 2 comments
Open

Emojis get escaped when serializing #400

ahartwel opened this issue Aug 17, 2023 · 2 comments

Comments

@ahartwel
Copy link

If a yaml string has emojis inside of it, after running serialize they are escaped in the final output.

For example

this:

test:
  a_key: "hello 🥹"
  another:
    test: "test"
    test2: "test2"

gets turned into

test:
  a_key: "hello \U0001F979"
  another:
    test: "test"
    test2: "test2"

after going through a Yams.compose -> Yams.serialize cycle.

Here's a simple repro:

let yaml = """
test:
  a_key: "hello 🥹"
  another:
    test: "test"
    test2: "test2"
"""

let node = try Yams.compose(yaml: yaml)
let newString = try Yams.serialize(node: node!, allowUnicode: true)
print(newString)
@samuelhe52
Copy link

samuelhe52 commented Jul 20, 2024

I encountered the exact same issue here. I'm using Yams.dump() to dump a dictionary:

import Foundation
import Yams

let testDict = ["testkey": "🔰test value with emoji"]

let desktopFolder = FileManager.default.urls(for: .desktopDirectory, in: .userDomainMask).first!

let ymlData = try Yams.dump(object: testDict).data(using: .utf8)!

try ymlData.write(to: desktopFolder.appending(path: "test.yaml"))

The result:

testkey: "\U0001F530test value with emoji"

Has anyone found a solution to this problem?

@acecilia
Copy link
Contributor

acecilia commented Dec 11, 2024

Seeing the same.

  • Seems like this is actually expected, see here
  • For other cases that are not emojis, using allowUnicode: true helps, like shown in here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants