[gedit-list] Mojibake (automissdetection)



#define WHAT_I_CAN_SPEAK {"Engrish", "Janglish"}

Hello.
I'm a gedit user in Japan.
When I open file with gedit, I encounter MOJIBAKE frequently.
At my seeing source, gedit's auto detection seems not enough.
I hope that gedit has better auto detection.
Following are my makeshift modification.

--

#include "encoding.c" // <-- from leafpad

gchar *
gedit_convert_to_utf8 (const gchar          *content,
		       gsize                 len,
		       const GeditEncoding **encoding,
		       gsize                *new_len,
		       GError              **error)
{
	gedit_debug (DEBUG_UTILS);

	g_return_val_if_fail (content != NULL, NULL);
	g_return_val_if_fail (encoding != NULL, NULL);

	if (len < 0)
		len = strlen (content);

	if (*encoding != NULL)
	{
		const gchar* charset;
		
		charset = gedit_encoding_get_charset (*encoding);

		g_return_val_if_fail (charset != NULL, NULL);

		return gedit_convert_to_utf8_from_charset (content,
							   len,
							   charset,
							   new_len,
							   error);
	}
	else
	{
		/* Automatically detect the encoding used */

		const gchar* charset;

		charset = detect_charset (content); // <-- from leafpad

		g_return_val_if_fail (charset != NULL, NULL);

		return gedit_convert_to_utf8_from_charset (content,
							   len,
							   charset,
							   new_len,
							   error);
	}

	g_return_val_if_reached (NULL);
}

--


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]