$OpenBSD: patch-datebook_c,v 1.1.1.1 2001/05/29 00:54:44 pvalchev Exp $
--- datebook.c.orig	Mon Feb  5 14:30:10 2001
+++ datebook.c	Sun May 27 17:12:01 2001
@@ -36,10 +36,6 @@
 #include "libplugin.h"
 #include "password.h"
 
-#include "japanese.h"
-#include "cp1250.h"
-#include "russian.h"
-
 #ifndef FALSE
 #define FALSE 0
 #endif
@@ -204,6 +200,13 @@ int pc_datebook_write(struct Appointment
    char record[65536];
    int rec_len;
    buf_rec br;
+   long char_set;
+
+   get_pref(PREF_CHAR_SET, &char_set, NULL);
+   if (char_set != CHAR_SET_ENGLISH) {
+       if (a->description) charset_j2p(a->description, strlen(a->description)+1, char_set);
+       if (a->note) charset_j2p(a->note, strlen(a->note)+1, char_set);
+   }
 
    rec_len = pack_Appointment(a, record, 65535);
    if (!rec_len) {
@@ -211,7 +214,7 @@ int pc_datebook_write(struct Appointment
       jpilot_logf(LOG_WARN, "pack_Appointment %s\n", _("error"));
       return -1;
    }
-   br.rt=rt;
+      br.rt=rt;
    br.attrib = attrib;
    br.buf = record;
    br.size = rec_len;
@@ -534,9 +537,10 @@ unsigned int isApptOnDate(struct Appoint
 
 int get_datebook_app_info(struct AppointmentAppInfo *ai)
 {
-   int num;
+   int num,i;
    unsigned int rec_size;
    unsigned char *buf;
+   long char_set;
 
    bzero(ai, sizeof(*ai));
 
@@ -549,6 +553,12 @@ int get_datebook_app_info(struct Appoint
       jpilot_logf(LOG_WARN, _("Error reading"), "DatebookDB.pdb");
       return -1;
    }
+   get_pref(PREF_CHAR_SET, &char_set, NULL);
+   if (char_set != CHAR_SET_ENGLISH) {
+      for (i = 0; i < 16; i++) {
+	  if (ai->category.name[i][0] != '\0') charset_p2j(ai->category.name[i], 16, char_set);
+      }
+   }
 	 
    return 0;
 }
@@ -687,14 +697,14 @@ int get_days_appointments2(AppointmentLi
    AppointmentList *temp_a_list;
    long keep_modified, keep_deleted;
    int keep_priv;
-   long char_set;
    buf_rec *br;
 #ifdef USE_DB3
    long use_db3_tags;
    time_t ltime;
    struct tm *today;
 #endif
-   
+   long char_set;
+
 #ifdef USE_DB3
    time(&ltime);
    today = localtime(&ltime);
@@ -762,22 +772,8 @@ int get_days_appointments2(AppointmentLi
       }
 
       get_pref(PREF_CHAR_SET, &char_set, NULL);
-      if (char_set==CHAR_SET_JAPANESE) {
-	 Sjis2Euc(a.description, 65536);
-	 Sjis2Euc(a.note, 65536);
-      }
-      if (char_set==CHAR_SET_1250) {
-	 Win2Lat(a.description, 65536);
-	 Win2Lat(a.note, 65536);
-      }
-      if (char_set==CHAR_SET_1251) {
-	 win1251_to_koi8(a.description, 65536);
-	 win1251_to_koi8(a.note, 65536);
-      }
-      if (char_set==CHAR_SET_1251_B) {
-	 koi8_to_win1251(a.description, 65536);
-	 koi8_to_win1251(a.note, 65536);
-      }
+      if (a.description) charset_p2j(a.description, strlen(a.description)+1, char_set);
+      if (a.note) charset_p2j(a.note, strlen(a.note)+1, char_set);
 
       temp_a_list = malloc(sizeof(AppointmentList));
       if (!temp_a_list) {
@@ -792,6 +788,8 @@ int get_days_appointments2(AppointmentLi
       temp_a_list->next = *appointment_list;
       *appointment_list = temp_a_list;
       recs_returned++;
+
+
    }
 
    jp_free_DB_records(&records);
@@ -802,3 +800,5 @@ int get_days_appointments2(AppointmentLi
 
    return recs_returned;
 }
+
+
