comparison Core/Enumerations.cpp @ 1090:e494ceb8d763

support more encodings
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 05 Aug 2014 12:04:23 +0200
parents e07b90fb00eb
children 200fcac0deb4
comparison
equal deleted inserted replaced
1089:5ea0b56e850d 1090:e494ceb8d763
296 return "Greek"; 296 return "Greek";
297 297
298 case Encoding_Hebrew: 298 case Encoding_Hebrew:
299 return "Hebrew"; 299 return "Hebrew";
300 300
301 case Encoding_Thai:
302 return "Thai";
303
304 case Encoding_Japanese:
305 return "Japanese";
306
307 case Encoding_Chinese:
308 return "Chinese";
309
301 default: 310 default:
302 throw OrthancException(ErrorCode_ParameterOutOfRange); 311 throw OrthancException(ErrorCode_ParameterOutOfRange);
303 } 312 }
304 } 313 }
305 314
360 } 369 }
361 370
362 if (s == "HEBREW") 371 if (s == "HEBREW")
363 { 372 {
364 return Encoding_Hebrew; 373 return Encoding_Hebrew;
374 }
375
376 if (s == "THAI")
377 {
378 return Encoding_Thai;
379 }
380
381 if (s == "JAPANESE")
382 {
383 return Encoding_Japanese;
384 }
385
386 if (s == "CHINESE")
387 {
388 return Encoding_Chinese;
365 } 389 }
366 390
367 throw OrthancException(ErrorCode_ParameterOutOfRange); 391 throw OrthancException(ErrorCode_ParameterOutOfRange);
368 } 392 }
369 393
428 452
429 default: 453 default:
430 throw OrthancException(ErrorCode_ParameterOutOfRange); 454 throw OrthancException(ErrorCode_ParameterOutOfRange);
431 } 455 }
432 } 456 }
457
458
459 bool GetDicomEncoding(Encoding& encoding,
460 const char* specificCharacterSet)
461 {
462 std::string s = specificCharacterSet;
463 Toolbox::ToUpperCase(s);
464
465 // http://www.dabsoft.ch/dicom/3/C.12.1.1.2/
466 // https://github.com/dcm4che/dcm4che/blob/master/dcm4che-core/src/main/java/org/dcm4che3/data/SpecificCharacterSet.java
467 if (s == "ISO_IR 6" ||
468 s == "ISO_IR 192" ||
469 s == "ISO 2022 IR 6")
470 {
471 encoding = Encoding_Utf8;
472 }
473 else if (s == "ISO_IR 100" ||
474 s == "ISO 2022 IR 100")
475 {
476 encoding = Encoding_Latin1;
477 }
478 else if (s == "ISO_IR 101" ||
479 s == "ISO 2022 IR 101")
480 {
481 encoding = Encoding_Latin2;
482 }
483 else if (s == "ISO_IR 109" ||
484 s == "ISO 2022 IR 109")
485 {
486 encoding = Encoding_Latin3;
487 }
488 else if (s == "ISO_IR 110" ||
489 s == "ISO 2022 IR 110")
490 {
491 encoding = Encoding_Latin4;
492 }
493 else if (s == "ISO_IR 148" ||
494 s == "ISO 2022 IR 148")
495 {
496 encoding = Encoding_Latin5;
497 }
498 else if (s == "ISO_IR 144" ||
499 s == "ISO 2022 IR 144")
500 {
501 encoding = Encoding_Cyrillic;
502 }
503 else if (s == "ISO_IR 127" ||
504 s == "ISO 2022 IR 127")
505 {
506 encoding = Encoding_Arabic;
507 }
508 else if (s == "ISO_IR 126" ||
509 s == "ISO 2022 IR 126")
510 {
511 encoding = Encoding_Greek;
512 }
513 else if (s == "ISO_IR 138" ||
514 s == "ISO 2022 IR 138")
515 {
516 encoding = Encoding_Hebrew;
517 }
518 else if (s == "ISO_IR 166" || s == "ISO 2022 IR 166")
519 {
520 encoding = Encoding_Thai;
521 }
522 else if (s == "ISO_IR 13" || s == "ISO 2022 IR 13")
523 {
524 encoding = Encoding_Japanese;
525 }
526 else if (s == "GB18030")
527 {
528 encoding = Encoding_Chinese;
529 }
530 /*
531 else if (s == "ISO 2022 IR 149")
532 {
533 TODO
534 }
535 else if (s == "ISO 2022 IR 159")
536 {
537 TODO
538 }
539 else if (s == "ISO 2022 IR 87")
540 {
541 TODO
542 }
543 */
544 else
545 {
546 return false;
547 }
548
549 // The encoding was properly detected
550 return true;
551 }
433 } 552 }