Title: commitizen_emoji cannot write to CHANGELOG · Issue #516 · commitizen-tools/commitizen · GitHub
Open Graph Title: commitizen_emoji cannot write to CHANGELOG · Issue #516 · commitizen-tools/commitizen
X Title: commitizen_emoji cannot write to CHANGELOG · Issue #516 · commitizen-tools/commitizen
Description: Description This is because commitizen_emoji uses unicode emoji characters, but commitizen does not specify the file encoding in write_changelog(), so it defaults back to cp1252: commitizen/commitizen/commands/changelog.py Line 92 in 791...
Open Graph Description: Description This is because commitizen_emoji uses unicode emoji characters, but commitizen does not specify the file encoding in write_changelog(), so it defaults back to cp1252: commitizen/commiti...
X Description: Description This is because commitizen_emoji uses unicode emoji characters, but commitizen does not specify the file encoding in write_changelog(), so it defaults back to cp1252: commitizen/commiti...
Opengraph URL: https://github.com/commitizen-tools/commitizen/issues/516
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"commitizen_emoji cannot write to CHANGELOG","articleBody":"### Description\n\nThis is because `commitizen_emoji` uses unicode emoji characters, but `commitizen` does not specify the file encoding in `write_changelog()`, so it defaults back to `cp1252`:\r\n\r\nhttps://github.com/commitizen-tools/commitizen/blob/79165119817cbd0aef25434a85dcbffa3a13acbb/commitizen/commands/changelog.py#L92\r\n\r\nThis could be fixed by specifying the `utf-8` encoding:\r\n\r\n```python\r\nwith open(self.file_name, \"w\", encoding='utf-8') as changelog_file: \r\n ...\r\n```\n\n### Steps to reproduce\n\n```\r\n\u003e cz bump --changelog\r\nbump: version 0.4.0 → 0.5.0\r\ntag to create: 0.5.0 \r\nincrement detected: MINOR \r\n\r\nTraceback (most recent call last):\r\n File \"C:\\Program Files\\Python38\\lib\\runpy.py\", line 194, in _run_module_as_main\r\n return _run_code(code, main_globals, None,\r\n File \"C:\\Program Files\\Python38\\lib\\runpy.py\", line 87, in _run_code\r\n exec(code, run_globals)\r\n File \"C:\\Users\\hendra11\\Code\\external\\cz-emoji\\.venv\\Scripts\\cz.exe\\__main__.py\", line 7, in \u003cmodule\u003e\r\n File \"C:\\Users\\hendra11\\Code\\external\\cz-emoji\\.venv\\lib\\site-packages\\commitizen\\cli.py\", line 382, in main\r\n args.func(conf, vars(args))()\r\n File \"C:\\Users\\hendra11\\Code\\external\\cz-emoji\\.venv\\lib\\site-packages\\commitizen\\commands\\bump.py\", line 215, in __call__\r\n changelog_cmd()\r\n File \"C:\\Users\\hendra11\\Code\\external\\cz-emoji\\.venv\\lib\\site-packages\\commitizen\\commands\\changelog.py\", line 172, in __call__\r\n self.write_changelog(changelog_out, lines, changelog_meta)\r\n File \"C:\\Users\\hendra11\\Code\\external\\cz-emoji\\.venv\\lib\\site-packages\\commitizen\\commands\\changelog.py\", line 103, in write_changelog\r\n changelog_file.write(changelog_out)\r\n File \"C:\\Program Files\\Python38\\lib\\encodings\\cp1252.py\", line 19, in encode\r\n return codecs.charmap_encode(input,self.errors,encoding_table)[0]\r\nUnicodeEncodeError: 'charmap' codec can't encode character '\\U0001f389' in position 29: character maps to \u003cundefined\u003e\r\n```\n\n### Current behavior\n\nSee `Steps to reproduce`\n\n### Desired behavior\n\nEmojis can be logged to changelog\n\n### Screenshots\n\n_No response_\n\n### Environment\n\n- cz version: 2.27.0\r\n- python version: 3.8.13\r\n- platform.system(): 'Windows'\r\n","author":{"url":"https://github.com/adam-grant-hendry","@type":"Person","name":"adam-grant-hendry"},"datePublished":"2022-05-22T02:41:11.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":12},"url":"https://github.com/516/commitizen/issues/516"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f82a9a23-1178-bd4c-5d96-8487ac49077c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E29C:356BEF:464E0:6254F:6978A00B |
| html-safe-nonce | b21be50dac65e0ca0accab0fe44c6ccc39c9e552de44615d0a07f112b59212a0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjlDOjM1NkJFRjo0NjRFMDo2MjU0Rjo2OTc4QTAwQiIsInZpc2l0b3JfaWQiOiI4MzcxOTcyODU0Njk3NzMwMDU5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2e5dc7cfb0ee08f8299e41b2390ff4ff01740af38660d373a72252a5dc5b30e1 |
| hovercard-subject-tag | issue:1244130490 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/commitizen-tools/commitizen/516/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c640547089036b8ef24659ea863f083d7163fe0c74bbfc44365ae1be1c22b5c5/commitizen-tools/commitizen/issues/516 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c640547089036b8ef24659ea863f083d7163fe0c74bbfc44365ae1be1c22b5c5/commitizen-tools/commitizen/issues/516 |
| og:image:alt | Description This is because commitizen_emoji uses unicode emoji characters, but commitizen does not specify the file encoding in write_changelog(), so it defaults back to cp1252: commitizen/commiti... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | adam-grant-hendry |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2981c597c945c1d90ac6fa355ce7929b2f413dfe7872ca5c435ee53a24a1de50 |
| turbo-cache-control | no-preview |
| go-import | github.com/commitizen-tools/commitizen git https://github.com/commitizen-tools/commitizen.git |
| octolytics-dimension-user_id | 62252524 |
| octolytics-dimension-user_login | commitizen-tools |
| octolytics-dimension-repository_id | 106127589 |
| octolytics-dimension-repository_nwo | commitizen-tools/commitizen |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 106127589 |
| octolytics-dimension-repository_network_root_nwo | commitizen-tools/commitizen |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 14920c7cb7d7c207b5e72684d0e6f23b65b849b3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width