diff options
| -rw-r--r-- | FL/Fl_Text_Buffer.H | 14 | ||||
| -rw-r--r-- | src/Fl_Text_Buffer.cxx | 30 | ||||
| -rw-r--r-- | test/editor.cxx | 2 |
3 files changed, 23 insertions, 23 deletions
diff --git a/FL/Fl_Text_Buffer.H b/FL/Fl_Text_Buffer.H index 1aaa4e792..14710d8c9 100644 --- a/FL/Fl_Text_Buffer.H +++ b/FL/Fl_Text_Buffer.H @@ -302,9 +302,9 @@ public: while reading data (data was partially loaded). File can be UTF-8 or CP1252-encoded. If the input file is not UTF-8-encoded, the Fl_Text_Buffer widget will contain - UTF-8-recoded data. By default, the message Fl_Text_Buffer::file_encoding_warning_message + UTF-8-transcoded data. By default, the message Fl_Text_Buffer::file_encoding_warning_message will warn the user about this. - \see input_file_was_reencoded and transcoding_warning_action. + \see input_file_was_transcoded and transcoding_warning_action. */ int insertfile(const char *file, int pos, int buflen = 128*1024); @@ -672,9 +672,9 @@ public: int utf8_align(int) const; /** - \brief true iff the loaded file has been re-encoded to UTF-8 + \brief true iff the loaded file has been transcoded to UTF-8 */ - int input_file_was_reencoded; + int input_file_was_transcoded; /** This message may be displayed using the fl_alert() function when a file which was not UTF-8 encoded is input. @@ -685,10 +685,10 @@ public: \brief Pointer to a function called after reading a non UTF-8 encoded file. This function is called after reading a file if the file content - was re-encoded to UTF-8. Its default implementation calls fl_alert() + was transcoded to UTF-8. Its default implementation calls fl_alert() with the text of \ref file_encoding_warning_message. No warning message is - displayed if this pointer is set to NULL. Use \ref input_file_was_reencoded - to be programmatically informed if file input required re-encoding to UTF-8. + displayed if this pointer is set to NULL. Use \ref input_file_was_transcoded + to be informed if file input required transcoding to UTF-8. */ void (*transcoding_warning_action)(Fl_Text_Buffer*); diff --git a/src/Fl_Text_Buffer.cxx b/src/Fl_Text_Buffer.cxx index 1d17ab120..34496abee 100644 --- a/src/Fl_Text_Buffer.cxx +++ b/src/Fl_Text_Buffer.cxx @@ -133,7 +133,7 @@ Fl_Text_Buffer::Fl_Text_Buffer(int requestedSize, int preferredGapSize) mPredeleteCbArgs = NULL; mCursorPosHint = 0; mCanUndo = 1; - input_file_was_reencoded = 0; + input_file_was_transcoded = 0; transcoding_warning_action = def_transcoding_warning_action; } @@ -1520,8 +1520,8 @@ int Fl_Text_Buffer::findchar_backward(int startPos, unsigned int searchChar, return 0; } -//#define FIXED_LENGTH_ENCODING // shows how to process any fixed-length encoding -#ifdef FIXED_LENGTH_ENCODING +//#define EXAMPLE_ENCODING // shows how to process any encoding for which a decoding function exists +#ifdef EXAMPLE_ENCODING // returns the UCS equivalent of *p in CP1252 and advances p by 1 unsigned cp1252toucs(char* &p) @@ -1539,7 +1539,7 @@ unsigned cp1252toucs(char* &p) return (uc < 0x80 || uc >= 0xa0 ? uc : cp1252[uc - 0x80]); } -// returns the UCS equivalent of *p in UTF-16 and advances p by 2 +// returns the UCS equivalent of *p in UTF-16 and advances p by 2 (or more for surrogates) unsigned utf16toucs(char* &p) { union { @@ -1557,11 +1557,11 @@ unsigned utf16toucs(char* &p) // filter that produces, from an input stream fed by reading from fp, // a UTF-8-encoded output stream written in buffer. -// Input can be any fixed-length (e.g., 8-bit, UTF-16) encoding. +// Input can be any (e.g., 8-bit, UTF-16) encoding. // Output is true UTF-8. -// p_trf points to a function that transforms encoded byte(s) into UCS +// p_trf points to a function that transforms encoded byte(s) into one UCS // and that increases the pointer by the adequate quantity -static int fixed_length_input_filter(char *buffer, int buflen, +static int general_input_filter(char *buffer, int buflen, char *line, int sline, char* &endline, unsigned (*p_trf)(char* &), FILE *fp) @@ -1590,7 +1590,7 @@ static int fixed_length_input_filter(char *buffer, int buflen, endline -= (p - line); return q - buffer; } -#endif // FIXED_LENGTH_ENCODING +#endif // EXAMPLE_ENCODING /* filter that produces, from an input stream fed by reading from fp, @@ -1645,7 +1645,7 @@ static int utf8_input_filter(char *buffer, int buflen, char *line, int sline, ch } const char *Fl_Text_Buffer::file_encoding_warning_message = -"Displayed text contains the UTF-8 re-encoding\n" +"Displayed text contains the UTF-8 transcoding\n" "of the input file which was not UTF-8 encoded.\n" "Some changes may have occurred."; @@ -1663,19 +1663,19 @@ const char *Fl_Text_Buffer::file_encoding_warning_message = char *buffer = new char[buflen + 1]; char *endline, line[100]; int l; - input_file_was_reencoded = false; + input_file_was_transcoded = false; endline = line; while (true) { -#ifdef FIXED_LENGTH_ENCODING +#ifdef EXAMPLE_ENCODING // example of 16-bit encoding: UTF-16 - l = fixed_length_input_filter(buffer, buflen, + l = general_input_filter(buffer, buflen, line, sizeof(line), endline, utf16toucs, // use cp1252toucs to read CP1252-encoded files fp); - input_file_was_reencoded = true; + input_file_was_transcoded = true; #else l = utf8_input_filter(buffer, buflen, line, sizeof(line), endline, - fp, &input_file_was_reencoded); + fp, &input_file_was_transcoded); #endif if (l == 0) break; buffer[l] = 0; @@ -1685,7 +1685,7 @@ const char *Fl_Text_Buffer::file_encoding_warning_message = int e = ferror(fp) ? 2 : 0; fclose(fp); delete[]buffer; - if ( (!e) && input_file_was_reencoded && transcoding_warning_action) { + if ( (!e) && input_file_was_transcoded && transcoding_warning_action) { transcoding_warning_action(this); } return e; diff --git a/test/editor.cxx b/test/editor.cxx index 92742ad48..722cd8199 100644 --- a/test/editor.cxx +++ b/test/editor.cxx @@ -492,7 +492,7 @@ void load_file(const char *newfile, int ipos) { int r; if (!insert) r = textbuf->loadfile(newfile); else r = textbuf->insertfile(newfile, ipos); - changed = changed || textbuf->input_file_was_reencoded; + changed = changed || textbuf->input_file_was_transcoded; if (r) fl_alert("Error reading from file \'%s\':\n%s.", newfile, strerror(errno)); else |
