Mercurial > hg > orthanc
comparison Core/DicomParsing/DicomWebJsonVisitor.cpp @ 3420:0a0e7eca95ae
fix encoding in DICOMweb
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 12 Jun 2019 12:11:58 +0200 |
parents | df0f1821b3de |
children | b3bdd6dc10f2 |
comparison
equal
deleted
inserted
replaced
3419:af271172cc36 | 3420:0a0e7eca95ae |
---|---|
519 else | 519 else |
520 { | 520 { |
521 Json::Value& node = CreateNode(parentTags, parentIndexes, tag); | 521 Json::Value& node = CreateNode(parentTags, parentIndexes, tag); |
522 node[KEY_VR] = EnumerationToString(vr); | 522 node[KEY_VR] = EnumerationToString(vr); |
523 | 523 |
524 #if 0 | |
525 /** | |
526 * TODO - The JSON file has an UTF-8 encoding, thus DCMTK | |
527 * replaces the specific character set with "ISO_IR 192" | |
528 * (UNICODE UTF-8). On Google Cloud Healthcare, however, the | |
529 * source encoding is reported, which seems more logical. We | |
530 * thus choose the Google convention. Enabling this block will | |
531 * mimic the DCMTK behavior. | |
532 **/ | |
524 if (tag == DICOM_TAG_SPECIFIC_CHARACTER_SET) | 533 if (tag == DICOM_TAG_SPECIFIC_CHARACTER_SET) |
525 { | 534 { |
526 // TODO - The JSON file has an UTF-8 encoding, thus DCMTK | |
527 // replaces the specific character set with "ISO_IR 192" | |
528 // (UNICODE UTF-8). It is unclear whether the source | |
529 // character set should be kept: We thus mimic DCMTK. | |
530 node[KEY_VALUE].append("ISO_IR 192"); | 535 node[KEY_VALUE].append("ISO_IR 192"); |
531 } | 536 } |
532 else | 537 else |
538 #endif | |
533 { | 539 { |
534 std::string truncated; | 540 std::string truncated; |
535 | 541 |
536 if (!value.empty() && | 542 if (!value.empty() && |
537 value[value.size() - 1] == '\0') | 543 value[value.size() - 1] == '\0') |
540 } | 546 } |
541 else | 547 else |
542 { | 548 { |
543 truncated = value; | 549 truncated = value; |
544 } | 550 } |
545 | 551 |
546 if (!truncated.empty()) | 552 if (!truncated.empty()) |
547 { | 553 { |
548 std::vector<std::string> tokens; | 554 std::vector<std::string> tokens; |
549 Toolbox::TokenizeString(tokens, truncated, '\\'); | 555 Toolbox::TokenizeString(tokens, truncated, '\\'); |
556 | |
557 if (tag == DICOM_TAG_SPECIFIC_CHARACTER_SET && | |
558 tokens.size() > 1 && | |
559 tokens[0].empty()) | |
560 { | |
561 std::string s = tokens[1]; | |
562 tokens.clear(); | |
563 tokens.push_back(s); | |
564 } | |
550 | 565 |
551 node[KEY_VALUE] = Json::arrayValue; | 566 node[KEY_VALUE] = Json::arrayValue; |
552 for (size_t i = 0; i < tokens.size(); i++) | 567 for (size_t i = 0; i < tokens.size(); i++) |
553 { | 568 { |
554 try | 569 try |