Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.7 KiB

  1. // =================================================================================
  2. // Internet Character Set Detection: For Korean
  3. // =================================================================================
  4. #include "private.h"
  5. #include "detcbase.h"
  6. #include "detckrn.h"
  7. #include "fechrcnv.h"
  8. #include "codepage.h"
  9. CIncdKorean::CIncdKorean()
  10. {
  11. m_nEscMode = NO_ESC ;
  12. m_bFindDesigator = FALSE ;
  13. m_nCharCount = 0 ;
  14. }
  15. BOOL CIncdKorean::DetectChar(UCHAR tc)
  16. {
  17. switch ( tc )
  18. {
  19. case ESC:
  20. if ( m_nEscMode == NO_ESC )
  21. m_nEscMode = sESC ;
  22. else
  23. m_nEscMode = NO_ESC ;
  24. break;
  25. case ISO2022_IN_CHAR : // '$'
  26. if ( m_nEscMode == sESC )
  27. m_nEscMode = sESC_1 ;
  28. else
  29. m_nEscMode = NO_ESC ;
  30. break;
  31. case ISO2022_IN_KR_CHAR_1 : // ')'
  32. if ( m_nEscMode == sESC_1 )
  33. m_nEscMode = sESC_2 ;
  34. else
  35. m_nEscMode = NO_ESC ;
  36. break;
  37. case ISO2022_IN_KR_CHAR_2 : // 'C'
  38. if ( m_nEscMode == sESC_2 )
  39. {
  40. m_bFindDesigator = TRUE ;
  41. return TRUE ;
  42. }
  43. break;
  44. default:
  45. m_nEscMode = NO_ESC ;
  46. break;
  47. }
  48. // only look ahead a max 1024 char
  49. if ( ++m_nCharCount > 1024 )
  50. return TRUE;
  51. return FALSE;
  52. }
  53. int CIncdKorean::GetDetectedCodeSet()
  54. {
  55. if ( m_bFindDesigator )
  56. return CP_ISO_2022_KR ; // ISO
  57. else
  58. return CP_KOR_5601 ; // Korean Windows
  59. }