Yams icon indicating copy to clipboard operation
Yams copied to clipboard

Unicode chars

Open erkekin opened this issue 5 years ago • 3 comments

It doesn't work with emojis and Japanese characters.

erkekin avatar Jan 24 '20 11:01 erkekin

Can you please share more information for us to look into this as a possible issue?

For what it's worth we have tests validating some multi-byte unicode character use cases: https://github.com/jpsim/Yams/blob/5fa313eae1ca127ad3c706e14c564399989cb1b1/Tests/YamsTests/SpecTests.swift#L19-L36

jpsim avatar Mar 01 '20 22:03 jpsim

I got something [wrong/not working as expect] with it I think

(PTFoundation.CodeClip) $R0 = {
  name = "测试/1"
  code = "echo \'test\'"
  section = "测试栏目+:/\\!#@$%#^$*(*&)"
  executor = nil
  target = nil
  targetLink = 0 values {}
}

resulting

name: "\u6D4B\u8BD5/1"
code: echo 'test'
section: "\u6D4B\u8BD5\u680F\u76EE+:/\\!#@$%#^$*(*&)"
executor: unknown
target: unknown
link: []

Lakr233 avatar Dec 24 '20 04:12 Lakr233

@Lakr233 as a workaround, you can apply a transformation to convert the Unicode codes into valid chars:

extension StringTransform {
    static let unicodeToAny = StringTransform("Hex-Any")
}

let yamlString = try? YAMLEncoder().encode(object)
return yamlString?.applyingTransform(.unicodeToAny, reverse: false)

leonidmelnyk avatar Sep 04 '23 12:09 leonidmelnyk