*** ./src/streamanalyzer/endanalyzers/textendanalyzer.cpp.org	2009-10-27 18:46:26.000000000 +0900
--- ./src/streamanalyzer/endanalyzers/textendanalyzer.cpp	2009-10-27 19:12:46.000000000 +0900
***************
*** 31,41 ****
--- 31,77 ----
  TextEndAnalyzerFactory::registerFields(FieldRegister& reg) {
  }
  
+ #ifndef ORIGINAL_CODE
+ static int __check_euc(const unsigned char *p, int size)
+ {
+     for (int i = 0; i < size; i++)
+     {
+ 	if (p[i] < 0x20)
+         {
+ 		if (p[i] > 0x07 && p[i] < 0x10)
+ 			continue;
+ 		return -1;
+ 	}
+ 	if (p[i] & 0x80)
+ 	{
+ 	 	if ((i+1) < size && (p[i+1] & 0x80))
+ 		{
+ 			i ++;
+ 			continue;
+ 		}
+ 		if (i == size - 1)
+ 			return 1;
+ 		return -1;
+ 	}
+     }
+     return 0;
+ }
+ #endif
+ 
  bool
  TextEndAnalyzer::checkHeader(const char* header, int32_t headersize) const {
      char nb;
      const char* last = checkUtf8(header, headersize, nb);
+ #ifdef	ORIGINAL_CODE
      return last == 0 || nb != 0;
+ #else
+     if (last == 0 || nb != 0)
+ 	return true;
+     if (__check_euc((const unsigned char *)header, headersize)>= 0)
+ 	return true;
+ 
+     return false;
+ #endif
  }
  
  signed char
***************
*** 59,64 ****
--- 95,116 ----
              retval = 0;
              idx.addText(b, last-b);
          }
+ #ifndef	ORIGINAL_CODE
+         else 
+         {
+ 		int error = __check_euc((const unsigned char *)b, nread);
+ 		if (error == 0)
+ 		{
+ 		    retval = 0;
+ 		    idx.addText(b, nread);
+ 		}
+ 		else if (error == 1)
+ 		{
+ 		    retval = 0;
+ 		    idx.addText(b, nread-1);
+ 		}
+ 	}
+ #endif
      }
      if (in->status() == Error) {
          m_error = in->error();
