*** src/LYBookmark.c.orig	Sun Apr 20 10:46:52 1997
--- src/LYBookmark.c	Wed Apr 30 11:01:55 1997
***************
*** 11,16 ****
--- 11,17 ----
  #include "LYCharUtils.h"
  #include "LYCurses.h"
  #include "GridText.h"
+ #include "HTCJK.h"
  
  #ifdef VMS
  #include "HTVMSUtils.h"
***************
*** 25,30 ****
--- 26,34 ----
  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 a bookmark file for reading, which may be
   *  the default, or based on offering the user a choice from
***************
*** 215,220 ****
--- 219,225 ----
      char *bookmark_URL = NULL;
      char filename_buffer[256];
      char string_buffer[256];
+     char tmp_buffer[512];
      char *Address = NULL;
      char *Title = NULL;
      int i, c;
***************
*** 284,290 ****
       *  Allow user to change the title. - FM
       */
      string_buffer[255] = '\0';
!     LYstrncpy(string_buffer, title, 255);
      convert_to_spaces(string_buffer, FALSE);
      LYMBM_statusline(TITLE_PROMPT);
      LYgetstr(string_buffer, VISIBLE, sizeof(string_buffer), NORECALL);
--- 289,309 ----
       *  Allow user to change the title. - FM
       */
      string_buffer[255] = '\0';
!     if (HTCJK == JAPANESE) {
! 	switch(kanji_code) {
! 	case EUC:
! 	    TO_EUC(title, tmp_buffer);
! 	    break;
! 	case SJIS:
! 	    TO_SJIS(title, tmp_buffer);
! 	    break;
! 	default:
! 	    break;
! 	}
! 	LYstrncpy(string_buffer, tmp_buffer, 255);
!     } else {
! 	LYstrncpy(string_buffer, title, 255);
!     }
      convert_to_spaces(string_buffer, FALSE);
      LYMBM_statusline(TITLE_PROMPT);
      LYgetstr(string_buffer, VISIBLE, sizeof(string_buffer), NORECALL);
***************
*** 300,306 ****
       *  converted to &lt; entities and any ampersands
       *  converted to &amp; entities.  - FM
       */
!     StrAllocCopy(Title, string_buffer);
      LYEntify(&Title, TRUE);
  
      /*
--- 319,330 ----
       *  converted to &lt; entities and any ampersands
       *  converted to &amp; entities.  - FM
       */
!     if (HTCJK == JAPANESE) {
! 	TO_JIS(string_buffer, tmp_buffer);
! 	StrAllocCopy(Title, tmp_buffer);
!     } else {
!         StrAllocCopy(Title, string_buffer);
!     }
      LYEntify(&Title, TRUE);
  
      /*
*** src/LYCharUtils.c.orig	Sun Apr 20 10:49:16 1997
--- src/LYCharUtils.c	Wed Apr 30 19:35:18 1997
***************
*** 909,914 ****
--- 909,918 ----
      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;
***************
*** 957,962 ****
--- 961,1046 ----
      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';
***************
*** 977,982 ****
--- 1061,1067 ----
  	    *q++ = *p;
  	}
      }
+     *q = '\0';
      StrAllocCopy(*str, cp);
  }
  
