diff --git a/man/rem2ps.1 b/man/rem2ps.1 index f373012e..c2c6a066 100644 --- a/man/rem2ps.1 +++ b/man/rem2ps.1 @@ -340,6 +340,10 @@ month (0 = Sunday, 1 = Monday, 6 = Saturday.) And \fImonday_first\fR is 1 if the \fB\-m\fR flag was supplied to \fBRemind\fR, or 0 if it was not. All this information is supplied so back-ends don't need any date calculation facilities. + +Note that all spaces in \fImonth_name\fR will be replaced with +underscores. Back-ends should undo this replacement. + .TP \fIsun mon tue wed thu fri sat\fR This line consists of @@ -347,6 +351,9 @@ space-separated names of days in whatever language \fBRemind\fR was compiled for. This information can be used by back-ends to annotate calendars, and means they don't have to be created for a specific language. + +Note that all spaces in day names will be replaced with +underscores. Back-ends should undo this replacement. .TP \fInext_mon next_days\fR The name of the next month and the number of days in it. diff --git a/rem2html/rem2html b/rem2html/rem2html index 449780d1..05c0df5b 100644 --- a/rem2html/rem2html +++ b/rem2html/rem2html @@ -248,12 +248,14 @@ sub parse_input return 0 unless $line; chomp($line); ($Prevmon, $Prevlen) = split(' ', $line); + $Prevmon =~ s/_/ /g; # Nextmon nextlen $line = ; return 0 unless $line; chomp($line); ($Nextmon, $Nextlen) = split(' ', $line); + $Nextmon =~ s/_/ /g; $found_data = 1; my $class; diff --git a/rem2pdf/lib/Remind/PDF.pm b/rem2pdf/lib/Remind/PDF.pm index 93dbc3c3..0234f18d 100644 --- a/rem2pdf/lib/Remind/PDF.pm +++ b/rem2pdf/lib/Remind/PDF.pm @@ -120,7 +120,6 @@ sub read_one_month # Month Year Days FirstWkday MondayFirst if ($line =~ /^(\S+) (\d+) (\d+) (\d+) (\d+)/) { $self->{monthname} = $1; - $self->{monthname} =~ s/_/ /g; $self->{year} = $2; $self->{daysinmonth} = $3; $self->{firstwkday} = $4; @@ -129,6 +128,7 @@ sub read_one_month return (undef, "Cannot interpret line: $line"); } + $self->{monthname} =~ s/_/ /g; # Day names $line = $in->getline(); chomp($line); @@ -155,6 +155,9 @@ sub read_one_month return (undef, "Cannot interpret line: $line"); } + $self->{prevmonthname} =~ s/_/ /g; + $self->{nextmonthname} =~ s/_/ /g; + if ($first_line eq '# rem2ps2 begin') { # remind -pp format return $self->read_one_month_pp($in, $specials_accepted); @@ -248,7 +251,7 @@ sub read_one_month_pp { my ($self, $in, $specials_accepted) = @_; - my $json = JSON::MaybeXS->new(utf8 => 1); + my $json = JSON::MaybeXS->new(utf8 => 0); my $line; while ($line = $in->getline()) { chomp($line); @@ -885,7 +888,7 @@ an error message. sub create_from_json { my ($class, $json, $specials_accepted) = @_; - my $parser = JSON::MaybeXS->new(utf8 => 1); + my $parser = JSON::MaybeXS->new(utf8 => 0); my $array; eval { @@ -904,12 +907,6 @@ sub create_from_json if (!$e) { return (undef, $error); } - # Re-encode our day names as utf-8 - my $new_day_names = []; - foreach my $d (@{$e->{daynames}}) { - push(@$new_day_names, Encode::encode('UTF-8', $d)); - } - $e->{daynames} = $new_day_names; push(@{$self->{entries}}, $e); } return ($self, undef); diff --git a/rem2pdf/lib/Remind/PDF/Entry.pm b/rem2pdf/lib/Remind/PDF/Entry.pm index e92e498f..02567322 100644 --- a/rem2pdf/lib/Remind/PDF/Entry.pm +++ b/rem2pdf/lib/Remind/PDF/Entry.pm @@ -76,7 +76,7 @@ sub render $layout->set_width(1024 * ($x2 - $x1 - 2 * $settings->{border_size})); $layout->set_wrap('word-char'); - $layout->set_text($self->{body}); + $layout->set_text(Encode::decode('UTF-8', $self->{body})); my $desc = Pango::FontDescription->from_string($settings->{entry_font} . ' ' . $settings->{entry_size} . 'px'); $layout->set_font_description($desc); my ($wid, $h) = $layout->get_pixel_size(); @@ -114,7 +114,7 @@ sub render my ($x1, $y1, $x2, $y2) = $pdf->col_box_coordinates($so_far, $col, $height, $settings); my $layout = Pango::Cairo::create_layout($cr); - $layout->set_text($self->{body}); + $layout->set_text(Encode::decode('UTF-8', $self->{body})); my $desc = Pango::FontDescription->from_string($settings->{entry_font} . ' ' . int(0.75 * $settings->{entry_size}) . 'px'); $layout->set_font_description($desc); my ($wid, $h) = $layout->get_pixel_size(); @@ -167,7 +167,7 @@ sub render if ($self->{body} ne '') { $layout = Pango::Cairo::create_layout($cr); - $layout->set_text($self->{body}); + $layout->set_text(Encode::decode('UTF-8', $self->{body})); my $desc = Pango::FontDescription->from_string($settings->{entry_font} . ' ' . $self->{fontsize} . 'px'); $layout->set_font_description($desc); ($bodywidth, undef) = $layout->get_pixel_size(); @@ -269,7 +269,7 @@ sub render $layout->set_width(1024 * ($x2 - $x1 - 2 * $settings->{border_size})); $layout->set_wrap('word-char'); - $layout->set_markup($self->{body}); + $layout->set_markup(Encode::decode('UTF-8', $self->{body})); if (($layout->get_text() // '') eq '') { # Invalid markup diff --git a/src/calendar.c b/src/calendar.c index 0722f747..c3d6d8f0 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -783,7 +783,7 @@ static void DoCalendarOneMonth(void) } else yy=y; if (PsCal < PSCAL_LEVEL3) { - printf("%s %d\n", get_month_name(mm), DaysInMonth(mm,yy)); + printf("%s %d\n", despace(get_month_name(mm)), DaysInMonth(mm,yy)); } else { PrintJSONKeyPairString("prevmonthname", get_month_name(mm)); PrintJSONKeyPairInt("daysinprevmonth", DaysInMonth(mm, yy)); @@ -794,7 +794,7 @@ static void DoCalendarOneMonth(void) mm = 0; yy = y+1; } else yy=y; if (PsCal < PSCAL_LEVEL3) { - printf("%s %d\n", get_month_name(mm), DaysInMonth(mm,yy)); + printf("%s %d\n", despace(get_month_name(mm)), DaysInMonth(mm,yy)); } else { PrintJSONKeyPairString("nextmonthname", get_month_name(mm)); PrintJSONKeyPairInt("daysinnextmonth", DaysInMonth(mm, yy)); diff --git a/src/rem2ps.c b/src/rem2ps.c index 7c7bcd62..191cd3fd 100644 --- a/src/rem2ps.c +++ b/src/rem2ps.c @@ -424,6 +424,19 @@ void DoPsCal(void) sscanf(DBufValue(&buf), "%s %d", prevm, &prevdays); DBufGets(&buf, stdin); sscanf(DBufValue(&buf), "%s %d", nextm, &nextdays); + + /* Replace underscores with spaces in names of next/prev month */ + s = prevm; + while(*s) { + if (*s == '_') *s = ' '; + s++; + } + s = nextm; + while(*s) { + if (*s == '_') *s = ' '; + s++; + } + DBufFree(&buf); MaxDay = days; FirstWkDay = wkday; diff --git a/tests/scripts.rem b/tests/scripts.rem index 1bf554b1..a9920edd 100644 --- a/tests/scripts.rem +++ b/tests/scripts.rem @@ -9,7 +9,20 @@ SET $Tuesday "mardi" SET $Wednesday "水曜日" SET $Thursday "четвер" SET $Friday "piątek" -Set $Saturday "שבת" +SET $Saturday "יום שבת" + +SET $January "January" +SET $February "février" +SET $March "März" +SET $April "אַפּרִיל" +SET $May "ግንቦት" +SET $June "Чэрвень" +SET $July "تموز" +SET $August "Наймдугаар сар" +SET $September "Вересень" +SET $October "październik" +SET $November "נאוועמבער" +SET $December "दिसंबर" REM 1 MSG Përkujtues REM 2 SPECIAL SHADE 192 192 255 @@ -18,7 +31,7 @@ REM 3 MSG 提醒 REM 4 MSG રીમાઇન્ડર REM 5 MSG Emlékeztető REM 6 MSG Áminning -REM 7 MSG תִזכּוֹרֶת +REM 7 SPECIAL PANGO תִזכּוֹרֶת REM 8 MSG अनुस्मारक REM 9 SPECIAL COLOR 0 0 192 Эскертүү REM 10 SPECIAL COLOR 0 192 0 Напоминание