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

Can't parse YAML that includes some emojis #174

Open
matthew-carroll opened this issue Dec 2, 2024 · 1 comment
Open

Can't parse YAML that includes some emojis #174

matthew-carroll opened this issue Dec 2, 2024 · 1 comment

Comments

@matthew-carroll
Copy link

matthew-carroll commented Dec 2, 2024

It seems that some set of emojis can't be parsed by this package.

yaml v3.1.2

Repro:

import 'package:yaml/yaml.dart' as yaml;

void main(List<String> args) async {
  _showYamlPackageBug();
}

void _showYamlPackageBug() {
  final data = yaml.loadYaml(_yaml);

  print("YAML:");
  print(data);
}

const _yaml = "title: 🤠 My Title ";

Error:

Unhandled exception:
Error on line 1, column 8: Unexpected character.
  ╷
1 │ title: 🤠 My Title 
  │        ^
  ╵
#0      Parser.parse (package:yaml/src/parser.dart:64:7)
#1      Loader._loadMapping (package:yaml/src/loader.dart:169:37)
#2      Loader._loadNode (package:yaml/src/loader.dart:92:16)
#3      Loader._loadDocument (package:yaml/src/loader.dart:68:20)
#4      Loader.load (package:yaml/src/loader.dart:60:20)
#5      loadYamlDocument (package:yaml/yaml.dart:72:25)
#6      loadYamlNode (package:yaml/yaml.dart:57:5)
#7      loadYaml (package:yaml/yaml.dart:44:5)
#8      _showYamlPackageBug (file:///home/user/frontmatter-emoji/bin/server.dart:21:21)
#9      main (file:///home/user/frontmatter-emoji/bin/server.dart:7:3)
#10     _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:294:33)
#11     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)
@Siddhant-K-code
Copy link

You can use 3.1.3-wip, which fixes a related issue.


As a workaround until 3.1.3 is released, you can wrap the emoji value in quotes:

title: "🤠 My Title"

Which would something like following:

import 'package:yaml/yaml.dart' as yaml;

void main(List<String> args) async {
  _showYamlPackageBug();
}

void _showYamlPackageBug() {
  final data = yaml.loadYaml('title: "🤠 My Title"');
  print("YAML:");
  print(data);
}

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

2 participants