*** src/LYBookmark.c.orig	Sun Sep  1 20:23:50 1996
--- src/LYBookmark.c	Wed Apr 30 19:59:32 1997
***************
*** 9,14 ****
--- 9,15 ----
  #include "LYSystem.h"
  #include "LYKeymap.h"
  #include "LYCharUtils.h"
+ #include "HTCJK.h"
  
  #ifdef VMS
  #include "HTVMSUtils.h"
***************
*** 22,27 ****
--- 23,31 ----
  PRIVATE BOOLEAN is_mosaic_hotlist=FALSE;
  PRIVATE char * convert_mosaic_bookmark_file PARAMS((char *filename_buffer));
  
+ extern HTkcode kanji_code;
+ extern HTCJKlang HTCJK;
+ 
  /*
   *  Tries to open the bookmark file for reading.
   *  if successful the file is closed and the filename
***************
*** 170,175 ****
--- 174,180 ----
      char filename_buffer[256];
      char *Address = NULL;
      char *Title = NULL;
+     char tmp[256];
  
      if (!(address && *address)) {
          HTAlert(MALFORMED_ADDRESS);
***************
*** 185,191 ****
       *  Allow user to change the title. - FM
       */
      filename_buffer[255] = '\0';
!     LYstrncpy(filename_buffer, title, 255);
      convert_to_spaces(filename_buffer);
      _statusline(TITLE_PROMPT); 
      LYgetstr(filename_buffer, VISIBLE, sizeof(filename_buffer), NORECALL);
--- 190,203 ----
       *  Allow user to change the title. - FM
       */
      filename_buffer[255] = '\0';
!     if ((HTCJK == JAPANESE) && (kanji_code == EUC)) {
! 	TO_EUC(title, tmp);
!     } else if ((HTCJK == JAPANESE) && (kanji_code == SJIS)) {
! 	TO_SJIS(title, tmp);
!     } else {
! 	strcpy(title ,tmp);
!     }
!     LYstrncpy(filename_buffer, tmp, 255);
      convert_to_spaces(filename_buffer);
      _statusline(TITLE_PROMPT); 
      LYgetstr(filename_buffer, VISIBLE, sizeof(filename_buffer), NORECALL);
***************
*** 199,205 ****
       *  Create the Title with any left-angle-brackets converted to &lt;
       *  entities and any ampersands converted to &amp; entities.  - FM
       */
!     StrAllocCopy(Title, filename_buffer);
      LYEntify(&Title, TRUE);
  
      /*
--- 211,222 ----
       *  Create the Title with any left-angle-brackets converted to &lt;
       *  entities and any ampersands converted to &amp; entities.  - FM
       */
!     if (HTCJK == JAPANESE) {
! 	TO_JIS(filename_buffer, tmp);
! 	StrAllocCopy(Title, tmp);
!     } else {
!         StrAllocCopy(Title, filename_buffer);
!     }
      LYEntify(&Title, TRUE);
  
      /*
*** src/LYCharUtils.c.orig	Sat Aug 31 18:07:52 1996
--- src/LYCharUtils.c	Wed Apr 30 19:54:49 1997
***************
*** 883,888 ****
--- 883,892 ----
      char *p = *str;
      char *q = NULL, *cp = NULL;
      int amps = 0, lts = 0, gts = 0;
+     enum _state
+         { S_text, S_esc, S_dollar, S_paren,
+           S_nonascii_text, S_dollar_paren } state = S_text;
+     int in_sjis = 0;
      
      if (p == NULL || *p == '\0')
          return;
***************
*** 931,936 ****
--- 935,1020 ----
      if ((cp = q) == NULL)
          outofmem(__FILE__, "LYEntify");
      for (p = *str; *p; p++) {
+ 	if (HTCJK != NOCJK) {
+ 	    switch(state) {
+ 		case S_text:
+ 		    if (*p == '\033') {
+ 			state = S_esc;
+ 			*q++ = *p;
+ 			continue;
+                     }
+                     break;
+ 
+ 		case S_esc:
+ 		    if (*p == '$') {
+ 			state = S_dollar;
+ 			*q++ = *p;
+ 			continue;
+ 		    } else if (*p == '(') {
+ 			state = S_paren;
+ 			*q++ = *p;
+ 			continue;
+ 		    } else {
+ 			state = S_text;
+ 			*q++ = *p;
+ 			continue;
+ 		    }
+ 
+ 		case S_dollar:
+ 		    if (*p == '@' || *p == 'B' || *p == 'A') {
+ 			state = S_nonascii_text;
+ 			*q++ = *p;
+ 			continue;
+ 		    } else if (*p == '(') {
+ 			state = S_dollar_paren;
+ 			*q++ = *p;
+ 			continue;
+ 		    } else {
+ 			state = S_text;
+ 			*q++ = *p;
+ 			continue;
+ 		    }
+ 
+ 		case S_dollar_paren:
+ 		    if (*p == 'C') {
+ 			state = S_nonascii_text;
+ 			*q++ = *p;
+ 			continue;
+ 		    } else {
+ 			state = S_text;
+ 			*q++ = *p;
+ 			continue;
+ 		    }
+ 
+ 		case S_paren:
+ 		    if (*p == 'B' || *p == 'J' || *p =='T') {
+ 			state = S_text;
+ 			*q++ = *p;
+ 			continue;
+ 		    } else if (*p == 'I') {
+ 			state = S_nonascii_text;
+ 			*q++ = *p;
+ 			continue;
+ 		    }
+ 
+ 		case S_nonascii_text:
+ 		    if (*p == '\033') 
+ 			state = S_esc;
+ 		    *q++ = *p;
+ 		    continue;
+ 
+ 		default:
+ 		    break;
+ 	    }
+ 	    if (*(p+1) != '\0' &&
+ 		(IS_EUC((unsigned char)*p, (unsigned char)*(p+1)) ||
+ 		 IS_SJIS((unsigned char)*p, (unsigned char)*(p+1), in_sjis) ||
+ 		 IS_BIG5((unsigned char)*p, (unsigned char)*(p+1)))) {
+ 		*q++ = *p++;
+ 		*q++ = *p;
+ 		continue;
+ 	    }
+ 	}
      	if (*p == '&') {
  	    *q++ = '&';
  	    *q++ = 'a';
***************
*** 951,956 ****
--- 1035,1041 ----
  	    *q++ = *p;
  	}
      }
+     *q = '\0';
      StrAllocCopy(*str, cp);
  
      return;
