{"action":"created","comment":{"url":"https://api.github.com/repos/pydicom/pydicom/pulls/comments/211820704","pull_request_review_id":148322972,"id":211820704,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMTgyMDcwNA==","diff_hunk":"@@ -51,18 +51,72 @@\n     'GBK': 'GBK',  # from DICOM correction CP1234\n }\n \n+# Map Python encodings to escape sequences as defined in PS3.3 in tables\n+# C.12-3 (single-byte) and C.12-4 (multi-byte character sets).\n+escape_codes = {\n+    'ascii': b'\\x1b(B',  # used to switch to ASCII G0 code element\n+    'iso8859': b'\\x1b-A',\n+    'shift_jis': b'\\x1b)I',\n+    'iso2022_jp': b'\\x1b$B',\n+    'iso8859_2': b'\\x1b-B',\n+    'iso8859_3': b'\\x1b-C',\n+    'iso8859_4': b'\\x1b-D',\n+    'iso_ir_126': b'\\x1b-F',\n+    'iso_ir_127': b'\\x1b-G',\n+    'iso_ir_138': b'\\x1b-H',\n+    'iso_ir_144': b'\\x1b-L',\n+    'iso_ir_148': b'\\x1b-M',\n+    'iso_ir_166': b'\\x1b-T',\n+    'euc_kr': b'\\x1b$)C',\n+    'iso-2022-jp': b'\\x1b$(D',\n+    'iso_ir_58': b'\\x1b$)A 58',\n+}\n+\n default_encoding = \"iso8859\"\n \n+ESCAPE = b'\\x1b'","path":"pydicom/charset.py","position":36,"original_position":36,"commit_id":"0351a42b3d198a49bd7cf59de3ec11e4d6ac8c60","original_commit_id":"0351a42b3d198a49bd7cf59de3ec11e4d6ac8c60","user":{"login":"scaramallion","id":10226372,"node_id":"MDQ6VXNlcjEwMjI2Mzcy","avatar_url":"https://avatars2.githubusercontent.com/u/10226372?v=4","gravatar_id":"","url":"https://api.github.com/users/scaramallion","html_url":"https://github.com/scaramallion","followers_url":"https://api.github.com/users/scaramallion/followers","following_url":"https://api.github.com/users/scaramallion/following{/other_user}","gists_url":"https://api.github.com/users/scaramallion/gists{/gist_id}","starred_url":"https://api.github.com/users/scaramallion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scaramallion/subscriptions","organizations_url":"https://api.github.com/users/scaramallion/orgs","repos_url":"https://api.github.com/users/scaramallion/repos","events_url":"https://api.github.com/users/scaramallion/events{/privacy}","received_events_url":"https://api.github.com/users/scaramallion/received_events","type":"User","site_admin":false},"body":"It took me like an hour to realise this was literally an 'ESCAPE' character rather than just a random byte string. Spend most of that time reading the standard to try and find where it came from...","created_at":"2018-08-22T03:36:30Z","updated_at":"2018-08-22T03:36:30Z","html_url":"https://github.com/pydicom/pydicom/pull/718#discussion_r211820704","pull_request_url":"https://api.github.com/repos/pydicom/pydicom/pulls/718","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pydicom/pydicom/pulls/comments/211820704"},"html":{"href":"https://github.com/pydicom/pydicom/pull/718#discussion_r211820704"},"pull_request":{"href":"https://api.github.com/repos/pydicom/pydicom/pulls/718"}}},"pull_request":{"url":"https://api.github.com/repos/pydicom/pydicom/pulls/718","id":209262583,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA5MjYyNTgz","html_url":"https://github.com/pydicom/pydicom/pull/718","diff_url":"https://github.com/pydicom/pydicom/pull/718.diff","patch_url":"https://github.com/pydicom/pydicom/pull/718.patch","issue_url":"https://api.github.com/repos/pydicom/pydicom/issues/718","number":718,"state":"open","locked":false,"title":"[MRG] Added handling of single-byte character set extensions","user":{"login":"mrbean-bremen","id":4623701,"node_id":"MDQ6VXNlcjQ2MjM3MDE=","avatar_url":"https://avatars1.githubusercontent.com/u/4623701?v=4","gravatar_id":"","url":"https://api.github.com/users/mrbean-bremen","html_url":"https://github.com/mrbean-bremen","followers_url":"https://api.github.com/users/mrbean-bremen/followers","following_url":"https://api.github.com/users/mrbean-bremen/following{/other_user}","gists_url":"https://api.github.com/users/mrbean-bremen/gists{/gist_id}","starred_url":"https://api.github.com/users/mrbean-bremen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrbean-bremen/subscriptions","organizations_url":"https://api.github.com/users/mrbean-bremen/orgs","repos_url":"https://api.github.com/users/mrbean-bremen/repos","events_url":"https://api.github.com/users/mrbean-bremen/events{/privacy}","received_events_url":"https://api.github.com/users/mrbean-bremen/received_events","type":"User","site_admin":false},"body":"- handle the list of encodings as given instead of 3 encodings\r\n- select the encoding for component groups based on escape codes\r\n- fixed decoding PatientName for of all charset example files\r\n- see #716\r\n\r\n<!--\r\nThanks for contributing a pull request! Please ensure you have taken a look at\r\nthe contribution guidelines: https://github.com/pydicom/pydicom/blob/master/CONTRIBUTING.md#contributing-pull-requests\r\n-->\r\n#### Reference Issue\r\n<!-- Example: Fixes #1234 -->\r\n\r\n\r\n#### What does this implement/fix? Explain your changes.\r\n\r\nThis is a first step at fixing the character encodings. There are still some things missing:\r\n- encoding reset after some whitespaces (newline, tab, line feed)\r\n- writing of encoded strings - here I'm not sure what the policy of writing changed tags is with respect to encoding\r\n- performance: the performance may degree due to encoding handling, I haven't checked yet if this has any real impact\r\n- handling of incorrect encodings\r\n\r\n<!--\r\nPlease summarize the key points of the reference issue, problem or contribution\r\nto facilitate reviewing task. Of course reviewers can always refer to the\r\noriginal issue but facilitating the reviewing process is much appreciated.\r\n-->\r\n\r\n#### Any other comments?\r\n<!--\r\n-->\r\n\r\n<!--\r\nPlease be aware that we are a loose team of volunteers so patience is\r\nnecessary; assistance handling other issues is very welcome. We value\r\nall user contributions, no matter how minor they are. If we are slow to\r\nreview, either the pull request needs some benchmarking, tinkering,\r\nconvincing, etc. or more likely the reviewers are simply busy. In either\r\ncase, we ask for your understanding during the review process.\r\n\r\nThanks for contributing!\r\n-->\r\n","created_at":"2018-08-17T21:32:43Z","updated_at":"2018-08-22T03:36:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"847d08de192dc0ab335ff3ad26d06ed902e92677","assignee":null,"assignees":[],"requested_reviewers":[{"login":"darcymason","id":61110,"node_id":"MDQ6VXNlcjYxMTEw","avatar_url":"https://avatars3.githubusercontent.com/u/61110?v=4","gravatar_id":"","url":"https://api.github.com/users/darcymason","html_url":"https://github.com/darcymason","followers_url":"https://api.github.com/users/darcymason/followers","following_url":"https://api.github.com/users/darcymason/following{/other_user}","gists_url":"https://api.github.com/users/darcymason/gists{/gist_id}","starred_url":"https://api.github.com/users/darcymason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darcymason/subscriptions","organizations_url":"https://api.github.com/users/darcymason/orgs","repos_url":"https://api.github.com/users/darcymason/repos","events_url":"https://api.github.com/users/darcymason/events{/privacy}","received_events_url":"https://api.github.com/users/darcymason/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/pydicom/pydicom/pulls/718/commits","review_comments_url":"https://api.github.com/repos/pydicom/pydicom/pulls/718/comments","review_comment_url":"https://api.github.com/repos/pydicom/pydicom/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pydicom/pydicom/issues/718/comments","statuses_url":"https://api.github.com/repos/pydicom/pydicom/statuses/0351a42b3d198a49bd7cf59de3ec11e4d6ac8c60","head":{"label":"mrbean-bremen:encodings","ref":"encodings","sha":"0351a42b3d198a49bd7cf59de3ec11e4d6ac8c60","user":{"login":"mrbean-bremen","id":4623701,"node_id":"MDQ6VXNlcjQ2MjM3MDE=","avatar_url":"https://avatars1.githubusercontent.com/u/4623701?v=4","gravatar_id":"","url":"https://api.github.com/users/mrbean-bremen","html_url":"https://github.com/mrbean-bremen","followers_url":"https://api.github.com/users/mrbean-bremen/followers","following_url":"https://api.github.com/users/mrbean-bremen/following{/other_user}","gists_url":"https://api.github.com/users/mrbean-bremen/gists{/gist_id}","starred_url":"https://api.github.com/users/mrbean-bremen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrbean-bremen/subscriptions","organizations_url":"https://api.github.com/users/mrbean-bremen/orgs","repos_url":"https://api.github.com/users/mrbean-bremen/repos","events_url":"https://api.github.com/users/mrbean-bremen/events{/privacy}","received_events_url":"https://api.github.com/users/mrbean-bremen/received_events","type":"User","site_admin":false},"repo":{"id":65673081,"node_id":"MDEwOlJlcG9zaXRvcnk2NTY3MzA4MQ==","name":"pydicom","full_name":"mrbean-bremen/pydicom","owner":{"login":"mrbean-bremen","id":4623701,"node_id":"MDQ6VXNlcjQ2MjM3MDE=","avatar_url":"https://avatars1.githubusercontent.com/u/4623701?v=4","gravatar_id":"","url":"https://api.github.com/users/mrbean-bremen","html_url":"https://github.com/mrbean-bremen","followers_url":"https://api.github.com/users/mrbean-bremen/followers","following_url":"https://api.github.com/users/mrbean-bremen/following{/other_user}","gists_url":"https://api.github.com/users/mrbean-bremen/gists{/gist_id}","starred_url":"https://api.github.com/users/mrbean-bremen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrbean-bremen/subscriptions","organizations_url":"https://api.github.com/users/mrbean-bremen/orgs","repos_url":"https://api.github.com/users/mrbean-bremen/repos","events_url":"https://api.github.com/users/mrbean-bremen/events{/privacy}","received_events_url":"https://api.github.com/users/mrbean-bremen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mrbean-bremen/pydicom","description":"Read, modify and write DICOM files with python code","fork":true,"url":"https://api.github.com/repos/mrbean-bremen/pydicom","forks_url":"https://api.github.com/repos/mrbean-bremen/pydicom/forks","keys_url":"https://api.github.com/repos/mrbean-bremen/pydicom/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mrbean-bremen/pydicom/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mrbean-bremen/pydicom/teams","hooks_url":"https://api.github.com/repos/mrbean-bremen/pydicom/hooks","issue_events_url":"https://api.github.com/repos/mrbean-bremen/pydicom/issues/events{/number}","events_url":"https://api.github.com/repos/mrbean-bremen/pydicom/events","assignees_url":"https://api.github.com/repos/mrbean-bremen/pydicom/assignees{/user}","branches_url":"https://api.github.com/repos/mrbean-bremen/pydicom/branches{/branch}","tags_url":"https://api.github.com/repos/mrbean-bremen/pydicom/tags","blobs_url":"https://api.github.com/repos/mrbean-bremen/pydicom/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mrbean-bremen/pydicom/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mrbean-bremen/pydicom/git/refs{/sha}","trees_url":"https://api.github.com/repos/mrbean-bremen/pydicom/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mrbean-bremen/pydicom/statuses/{sha}","languages_url":"https://api.github.com/repos/mrbean-bremen/pydicom/languages","stargazers_url":"https://api.github.com/repos/mrbean-bremen/pydicom/stargazers","contributors_url":"https://api.github.com/repos/mrbean-bremen/pydicom/contributors","subscribers_url":"https://api.github.com/repos/mrbean-bremen/pydicom/subscribers","subscription_url":"https://api.github.com/repos/mrbean-bremen/pydicom/subscription","commits_url":"https://api.github.com/repos/mrbean-bremen/pydicom/commits{/sha}","git_commits_url":"https://api.github.com/repos/mrbean-bremen/pydicom/git/commits{/sha}","comments_url":"https://api.github.com/repos/mrbean-bremen/pydicom/comments{/number}","issue_comment_url":"https://api.github.com/repos/mrbean-bremen/pydicom/issues/comments{/number}","contents_url":"https://api.github.com/repos/mrbean-bremen/pydicom/contents/{+path}","compare_url":"https://api.github.com/repos/mrbean-bremen/pydicom/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mrbean-bremen/pydicom/merges","archive_url":"https://api.github.com/repos/mrbean-bremen/pydicom/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mrbean-bremen/pydicom/downloads","issues_url":"https://api.github.com/repos/mrbean-bremen/pydicom/issues{/number}","pulls_url":"https://api.github.com/repos/mrbean-bremen/pydicom/pulls{/number}","milestones_url":"https://api.github.com/repos/mrbean-bremen/pydicom/milestones{/number}","notifications_url":"https://api.github.com/repos/mrbean-bremen/pydicom/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mrbean-bremen/pydicom/labels{/name}","releases_url":"https://api.github.com/repos/mrbean-bremen/pydicom/releases{/id}","deployments_url":"https://api.github.com/repos/mrbean-bremen/pydicom/deployments","created_at":"2016-08-14T15:31:07Z","updated_at":"2018-07-01T18:38:41Z","pushed_at":"2018-08-21T18:40:48Z","git_url":"git://github.com/mrbean-bremen/pydicom.git","ssh_url":"git@github.com:mrbean-bremen/pydicom.git","clone_url":"https://github.com/mrbean-bremen/pydicom.git","svn_url":"https://github.com/mrbean-bremen/pydicom","homepage":null,"size":14864,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pydicom:master","ref":"master","sha":"87b40f8daeb618e6c92eaffbe9d1088b05bed50e","user":{"login":"pydicom","id":28906941,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4OTA2OTQx","avatar_url":"https://avatars2.githubusercontent.com/u/28906941?v=4","gravatar_id":"","url":"https://api.github.com/users/pydicom","html_url":"https://github.com/pydicom","followers_url":"https://api.github.com/users/pydicom/followers","following_url":"https://api.github.com/users/pydicom/following{/other_user}","gists_url":"https://api.github.com/users/pydicom/gists{/gist_id}","starred_url":"https://api.github.com/users/pydicom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pydicom/subscriptions","organizations_url":"https://api.github.com/users/pydicom/orgs","repos_url":"https://api.github.com/users/pydicom/repos","events_url":"https://api.github.com/users/pydicom/events{/privacy}","received_events_url":"https://api.github.com/users/pydicom/received_events","type":"Organization","site_admin":false},"repo":{"id":14006067,"node_id":"MDEwOlJlcG9zaXRvcnkxNDAwNjA2Nw==","name":"pydicom","full_name":"pydicom/pydicom","owner":{"login":"pydicom","id":28906941,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4OTA2OTQx","avatar_url":"https://avatars2.githubusercontent.com/u/28906941?v=4","gravatar_id":"","url":"https://api.github.com/users/pydicom","html_url":"https://github.com/pydicom","followers_url":"https://api.github.com/users/pydicom/followers","following_url":"https://api.github.com/users/pydicom/following{/other_user}","gists_url":"https://api.github.com/users/pydicom/gists{/gist_id}","starred_url":"https://api.github.com/users/pydicom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pydicom/subscriptions","organizations_url":"https://api.github.com/users/pydicom/orgs","repos_url":"https://api.github.com/users/pydicom/repos","events_url":"https://api.github.com/users/pydicom/events{/privacy}","received_events_url":"https://api.github.com/users/pydicom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pydicom/pydicom","description":"Read, modify and write DICOM files with python code","fork":false,"url":"https://api.github.com/repos/pydicom/pydicom","forks_url":"https://api.github.com/repos/pydicom/pydicom/forks","keys_url":"https://api.github.com/repos/pydicom/pydicom/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pydicom/pydicom/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pydicom/pydicom/teams","hooks_url":"https://api.github.com/repos/pydicom/pydicom/hooks","issue_events_url":"https://api.github.com/repos/pydicom/pydicom/issues/events{/number}","events_url":"https://api.github.com/repos/pydicom/pydicom/events","assignees_url":"https://api.github.com/repos/pydicom/pydicom/assignees{/user}","branches_url":"https://api.github.com/repos/pydicom/pydicom/branches{/branch}","tags_url":"https://api.github.com/repos/pydicom/pydicom/tags","blobs_url":"https://api.github.com/repos/pydicom/pydicom/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pydicom/pydicom/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pydicom/pydicom/git/refs{/sha}","trees_url":"https://api.github.com/repos/pydicom/pydicom/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pydicom/pydicom/statuses/{sha}","languages_url":"https://api.github.com/repos/pydicom/pydicom/languages","stargazers_url":"https://api.github.com/repos/pydicom/pydicom/stargazers","contributors_url":"https://api.github.com/repos/pydicom/pydicom/contributors","subscribers_url":"https://api.github.com/repos/pydicom/pydicom/subscribers","subscription_url":"https://api.github.com/repos/pydicom/pydicom/subscription","commits_url":"https://api.github.com/repos/pydicom/pydicom/commits{/sha}","git_commits_url":"https://api.github.com/repos/pydicom/pydicom/git/commits{/sha}","comments_url":"https://api.github.com/repos/pydicom/pydicom/comments{/number}","issue_comment_url":"https://api.github.com/repos/pydicom/pydicom/issues/comments{/number}","contents_url":"https://api.github.com/repos/pydicom/pydicom/contents/{+path}","compare_url":"https://api.github.com/repos/pydicom/pydicom/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pydicom/pydicom/merges","archive_url":"https://api.github.com/repos/pydicom/pydicom/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pydicom/pydicom/downloads","issues_url":"https://api.github.com/repos/pydicom/pydicom/issues{/number}","pulls_url":"https://api.github.com/repos/pydicom/pydicom/pulls{/number}","milestones_url":"https://api.github.com/repos/pydicom/pydicom/milestones{/number}","notifications_url":"https://api.github.com/repos/pydicom/pydicom/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pydicom/pydicom/labels{/name}","releases_url":"https://api.github.com/repos/pydicom/pydicom/releases{/id}","deployments_url":"https://api.github.com/repos/pydicom/pydicom/deployments","created_at":"2013-10-31T02:58:52Z","updated_at":"2018-08-22T01:56:31Z","pushed_at":"2018-08-21T18:40:50Z","git_url":"git://github.com/pydicom/pydicom.git","ssh_url":"git@github.com:pydicom/pydicom.git","clone_url":"https://github.com/pydicom/pydicom.git","svn_url":"https://github.com/pydicom/pydicom","homepage":null,"size":24498,"stargazers_count":467,"watchers_count":467,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":210,"mirror_url":null,"archived":false,"open_issues_count":61,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":210,"open_issues":61,"watchers":467,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pydicom/pydicom/pulls/718"},"html":{"href":"https://github.com/pydicom/pydicom/pull/718"},"issue":{"href":"https://api.github.com/repos/pydicom/pydicom/issues/718"},"comments":{"href":"https://api.github.com/repos/pydicom/pydicom/issues/718/comments"},"review_comments":{"href":"https://api.github.com/repos/pydicom/pydicom/pulls/718/comments"},"review_comment":{"href":"https://api.github.com/repos/pydicom/pydicom/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pydicom/pydicom/pulls/718/commits"},"statuses":{"href":"https://api.github.com/repos/pydicom/pydicom/statuses/0351a42b3d198a49bd7cf59de3ec11e4d6ac8c60"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"scaramallion"}}