Skip to content

Commit

Permalink
Add support for page 1252 encoding
Browse files Browse the repository at this point in the history
Rdrview is failing to handle pages that use the Windows-1252 encoding:

  #15

Just like GB2312, this encoding is only supported via iconv, not
directly by libxml2. Since iconv conversions need to read files from
disk, initialize the conversion descriptor before setting up the
sandbox.
  • Loading branch information
eafer committed Jan 25, 2021
1 parent be554df commit 1a7b95a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/rdrview.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,8 +769,9 @@ static inline void assert_sandbox_works(void)
}
#endif /* NDEBUG */

/* Descriptors for the encodings supported via iconv; for now only GB2312 */
/* Descriptors for the encodings supported via iconv */
static iconv_t gb2312_cd;
static iconv_t cp1252_cd;

/**
* Set up the iconv conversion descriptors to be used by libxml2. This is
Expand All @@ -781,6 +782,10 @@ static void init_iconv(void)
gb2312_cd = iconv_open("UTF-8", "GB2312");
if (gb2312_cd == (iconv_t)(-1))
fatal_errno();

cp1252_cd = iconv_open("UTF-8", "CP1252");
if (cp1252_cd == (iconv_t)(-1))
fatal_errno();
}

/**
Expand All @@ -789,6 +794,7 @@ static void init_iconv(void)
static void clean_iconv(void)
{
iconv_close(gb2312_cd);
iconv_close(cp1252_cd);
}

/**
Expand Down

0 comments on commit 1a7b95a

Please sign in to comment.