mirror of https://github.com/fltk/fltk
Fix spelling errors and improve documentation.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10759 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
769b35770a
commit
5573c35ff1
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Simple "C"-style types for the Fast Light Tool Kit (FLTK).
|
||||
*
|
||||
* Copyright 1998-2010 by Bill Spitzak and others.
|
||||
* Copyright 1998-2015 by Bill Spitzak and others.
|
||||
*
|
||||
* This library is free software. Distribution and use rights are outlined in
|
||||
* the file "COPYING" which should have been included with this file. If this
|
||||
|
@ -16,7 +16,7 @@
|
|||
* http://www.fltk.org/str.php
|
||||
*/
|
||||
|
||||
/** \file
|
||||
/** \file
|
||||
* This file contains simple "C"-style type definitions.
|
||||
*/
|
||||
|
||||
|
@ -31,13 +31,13 @@ typedef unsigned char uchar;
|
|||
/** unsigned long */
|
||||
typedef unsigned long ulong;
|
||||
|
||||
/** Flexible length utf8 Unicode text
|
||||
/** Flexible length UTF-8 Unicode text.
|
||||
*
|
||||
* \todo FIXME: temporary (?) typedef to mark UTF8 and Unicode conversions
|
||||
* \todo FIXME: temporary (?) typedef to mark UTF-8 and Unicode conversions
|
||||
*/
|
||||
typedef char *Fl_String;
|
||||
|
||||
/** Flexible length utf8 Unicode read-only string
|
||||
/** Flexible length UTF-8 Unicode read-only string.
|
||||
* \sa Fl_String
|
||||
*/
|
||||
typedef const char *Fl_CString;
|
||||
|
@ -45,9 +45,9 @@ typedef const char *Fl_CString;
|
|||
/** 24-bit Unicode character + 8-bit indicator for keyboard flags */
|
||||
typedef unsigned int Fl_Shortcut;
|
||||
|
||||
/** 24-bit Unicode character - upper 8-bits are unused */
|
||||
/** 24-bit Unicode character - upper 8 bits are unused */
|
||||
typedef unsigned int Fl_Char;
|
||||
|
||||
|
||||
/*@}*/ /* group: Miscellaneous */
|
||||
|
||||
#endif
|
||||
|
|
81
FL/fl_utf8.h
81
FL/fl_utf8.h
|
@ -1,4 +1,5 @@
|
|||
/* "$Id$"
|
||||
/*
|
||||
* "$Id$"
|
||||
*
|
||||
* Author: Jean-Marc Lienher ( http://oksid.ch )
|
||||
* Copyright 2000-2010 by O'ksi'D.
|
||||
|
@ -21,7 +22,7 @@
|
|||
|
||||
/**
|
||||
\file fl_utf8.h
|
||||
\brief header for Unicode and UTF8 chracter handling
|
||||
\brief header for Unicode and UTF-8 chracter handling
|
||||
*/
|
||||
|
||||
#ifndef _HAVE_FL_UTF8_HDR_
|
||||
|
@ -65,9 +66,9 @@
|
|||
# define xchar unsigned short
|
||||
#endif
|
||||
|
||||
# ifdef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/** \addtogroup fl_unicode
|
||||
@{
|
||||
|
@ -77,7 +78,7 @@ extern "C" {
|
|||
/* OD: comes from OksiD */
|
||||
|
||||
/**
|
||||
Return the number of bytes needed to encode the given UCS4 character in UTF8.
|
||||
Return the number of bytes needed to encode the given UCS4 character in UTF-8.
|
||||
\param [in] ucs UCS4 encoded character
|
||||
\return number of bytes required
|
||||
*/
|
||||
|
@ -92,44 +93,44 @@ FL_EXPORT int fl_utf8len1(char c);
|
|||
/* OD: returns the number of Unicode chars in the UTF-8 string */
|
||||
FL_EXPORT int fl_utf_nb_char(const unsigned char *buf, int len);
|
||||
|
||||
/* F2: Convert the next UTF8 char-sequence into a Unicode value (and say how many bytes were used) */
|
||||
/* F2: Convert the next UTF-8 char-sequence into a Unicode value (and say how many bytes were used) */
|
||||
FL_EXPORT unsigned fl_utf8decode(const char* p, const char* end, int* len);
|
||||
|
||||
/* F2: Encode a Unicode value into a UTF8 sequence, return the number of bytes used */
|
||||
/* F2: Encode a Unicode value into a UTF-8 sequence, return the number of bytes used */
|
||||
FL_EXPORT int fl_utf8encode(unsigned ucs, char* buf);
|
||||
|
||||
/* F2: Move forward to the next valid UTF8 sequence start betwen start and end */
|
||||
/* F2: Move forward to the next valid UTF-8 sequence start betwen start and end */
|
||||
FL_EXPORT const char* fl_utf8fwd(const char* p, const char* start, const char* end);
|
||||
|
||||
/* F2: Move backward to the previous valid UTF8 sequence start */
|
||||
/* F2: Move backward to the previous valid UTF-8 sequence start */
|
||||
FL_EXPORT const char* fl_utf8back(const char* p, const char* start, const char* end);
|
||||
|
||||
/* XX: Convert a single 32-bit Unicode value into UTF16 */
|
||||
FL_EXPORT unsigned fl_ucs_to_Utf16(const unsigned ucs, unsigned short *dst, const unsigned dstlen);
|
||||
|
||||
/* F2: Convert a UTF8 string into UTF16 */
|
||||
/* F2: Convert a UTF-8 string into UTF16 */
|
||||
FL_EXPORT unsigned fl_utf8toUtf16(const char* src, unsigned srclen, unsigned short* dst, unsigned dstlen);
|
||||
|
||||
/* F2: Convert a UTF8 string into a wide character string - makes UTF16 on win32, "UCS4" elsewhere */
|
||||
/* F2: Convert a UTF-8 string into a wide character string - makes UTF16 on win32, "UCS4" elsewhere */
|
||||
FL_EXPORT unsigned fl_utf8towc(const char *src, unsigned srclen, wchar_t *dst, unsigned dstlen);
|
||||
|
||||
/* F2: Convert a wide character string to UTF8 - takes in UTF16 on win32, "UCS4" elsewhere */
|
||||
/* F2: Convert a wide character string to UTF-8 - takes in UTF16 on win32, "UCS4" elsewhere */
|
||||
FL_EXPORT unsigned fl_utf8fromwc(char *dst, unsigned dstlen, const wchar_t *src, unsigned srclen);
|
||||
|
||||
/* F2: Convert a UTF8 string into ASCII, eliding untranslatable glyphs */
|
||||
/* F2: Convert a UTF-8 string into ASCII, eliding untranslatable glyphs */
|
||||
FL_EXPORT unsigned fl_utf8toa (const char *src, unsigned srclen, char *dst, unsigned dstlen);
|
||||
/* OD: convert UTF-8 string to latin1 */
|
||||
/* FL_EXPORT int fl_utf2latin1(const unsigned char *src, int srclen, char *dst); */
|
||||
|
||||
/* F2: Convert 8859-1 string to UTF8 */
|
||||
/* F2: Convert 8859-1 string to UTF-8 */
|
||||
FL_EXPORT unsigned fl_utf8froma (char *dst, unsigned dstlen, const char *src, unsigned srclen);
|
||||
/* OD: convert latin1 str to UTF-8 */
|
||||
/* FL_EXPORT int fl_latin12utf(const unsigned char *src, int srclen, char *dst); */
|
||||
|
||||
/* F2: Returns true if the current O/S locale is UTF8 */
|
||||
/* F2: Returns true if the current O/S locale is UTF-8 */
|
||||
FL_EXPORT int fl_utf8locale();
|
||||
|
||||
/* F2: Examine the first len characters of src, to determine if the input text is UTF8 or not
|
||||
/* F2: Examine the first len characters of src, to determine if the input text is UTF-8 or not
|
||||
* NOTE: The value returned is not simply boolean - it contains information about the probable
|
||||
* type of the src text. */
|
||||
FL_EXPORT int fl_utf8test(const char *src, unsigned len);
|
||||
|
@ -146,34 +147,34 @@ FL_EXPORT int fl_wcwidth(const char *src);
|
|||
/* OD: Return true if the character is non-spacing */
|
||||
FL_EXPORT unsigned int fl_nonspacing(unsigned int ucs);
|
||||
|
||||
/* F2: Convert UTF8 to a local multi-byte encoding - mainly for win32? */
|
||||
/* F2: Convert UTF-8 to a local multi-byte encoding - mainly for win32? */
|
||||
FL_EXPORT unsigned fl_utf8to_mb(const char *src, unsigned srclen, char *dst, unsigned dstlen);
|
||||
/* OD: Convert UTF8 to a local multi-byte encoding */
|
||||
/* OD: Convert UTF-8 to a local multi-byte encoding */
|
||||
FL_EXPORT char* fl_utf2mbcs(const char *src);
|
||||
|
||||
/* F2: Convert a local multi-byte encoding to UTF8 - mainly for win32? */
|
||||
/* F2: Convert a local multi-byte encoding to UTF-8 - mainly for win32? */
|
||||
FL_EXPORT unsigned fl_utf8from_mb(char *dst, unsigned dstlen, const char *src, unsigned srclen);
|
||||
/* OD: Convert a local multi-byte encoding to UTF8 */
|
||||
/* OD: Convert a local multi-byte encoding to UTF-8 */
|
||||
/* FL_EXPORT char* fl_mbcs2utf(const char *src); */
|
||||
|
||||
/*****************************************************************************/
|
||||
#ifdef WIN32
|
||||
/* OD: Attempt to convert the UTF8 string to the current locale */
|
||||
/* OD: Attempt to convert the UTF-8 string to the current locale */
|
||||
FL_EXPORT char *fl_utf8_to_locale(const char *s, int len, unsigned int codepage);
|
||||
|
||||
/* OD: Attempt to convert a string in the current locale to UTF8 */
|
||||
/* OD: Attempt to convert a string in the current locale to UTF-8 */
|
||||
FL_EXPORT char *fl_locale_to_utf8(const char *s, int len, unsigned int codepage);
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* The following functions are intended to provide portable, UTF8 aware
|
||||
* The following functions are intended to provide portable, UTF-8 aware
|
||||
* versions of standard functions
|
||||
*/
|
||||
|
||||
/* OD: UTF8 aware strncasecmp - converts to lower case Unicode and tests */
|
||||
/* OD: UTF-8 aware strncasecmp - converts to lower case Unicode and tests */
|
||||
FL_EXPORT int fl_utf_strncasecmp(const char *s1, const char *s2, int n);
|
||||
|
||||
/* OD: UTF8 aware strcasecmp - converts to Unicode and tests */
|
||||
/* OD: UTF-8 aware strcasecmp - converts to Unicode and tests */
|
||||
FL_EXPORT int fl_utf_strcasecmp(const char *s1, const char *s2);
|
||||
|
||||
/* OD: return the Unicode lower case value of ucs */
|
||||
|
@ -182,49 +183,49 @@ FL_EXPORT int fl_tolower(unsigned int ucs);
|
|||
/* OD: return the Unicode upper case value of ucs */
|
||||
FL_EXPORT int fl_toupper(unsigned int ucs);
|
||||
|
||||
/* OD: converts the UTF8 string to the lower case equivalent */
|
||||
/* OD: converts the UTF-8 string to the lower case equivalent */
|
||||
FL_EXPORT int fl_utf_tolower(const unsigned char *str, int len, char *buf);
|
||||
|
||||
/* OD: converts the UTF8 string to the upper case equivalent */
|
||||
/* OD: converts the UTF-8 string to the upper case equivalent */
|
||||
FL_EXPORT int fl_utf_toupper(const unsigned char *str, int len, char *buf);
|
||||
|
||||
/* OD: Portable UTF8 aware chmod wrapper */
|
||||
/* OD: Portable UTF-8 aware chmod wrapper */
|
||||
FL_EXPORT int fl_chmod(const char* f, int mode);
|
||||
|
||||
/* OD: Portable UTF8 aware access wrapper */
|
||||
/* OD: Portable UTF-8 aware access wrapper */
|
||||
FL_EXPORT int fl_access(const char* f, int mode);
|
||||
|
||||
/* OD: Portable UTF8 aware stat wrapper */
|
||||
/* OD: Portable UTF-8 aware stat wrapper */
|
||||
FL_EXPORT int fl_stat( const char *path, struct stat *buffer );
|
||||
|
||||
/* OD: Portable UTF8 aware getcwd wrapper */
|
||||
/* OD: Portable UTF-8 aware getcwd wrapper */
|
||||
FL_EXPORT char* fl_getcwd( char *buf, int maxlen);
|
||||
|
||||
/* OD: Portable UTF8 aware fopen wrapper */
|
||||
/* OD: Portable UTF-8 aware fopen wrapper */
|
||||
FL_EXPORT FILE *fl_fopen(const char *f, const char *mode);
|
||||
|
||||
/* OD: Portable UTF8 aware system wrapper */
|
||||
/* OD: Portable UTF-8 aware system wrapper */
|
||||
FL_EXPORT int fl_system(const char* f);
|
||||
|
||||
/* OD: Portable UTF8 aware execvp wrapper */
|
||||
/* OD: Portable UTF-8 aware execvp wrapper */
|
||||
FL_EXPORT int fl_execvp(const char *file, char *const *argv);
|
||||
|
||||
/* OD: Portable UTF8 aware open wrapper */
|
||||
/* OD: Portable UTF-8 aware open wrapper */
|
||||
FL_EXPORT int fl_open(const char* f, int o, ...);
|
||||
|
||||
/* OD: Portable UTF8 aware unlink wrapper */
|
||||
/* OD: Portable UTF-8 aware unlink wrapper */
|
||||
FL_EXPORT int fl_unlink(const char *f);
|
||||
|
||||
/* OD: Portable UTF8 aware rmdir wrapper */
|
||||
/* OD: Portable UTF-8 aware rmdir wrapper */
|
||||
FL_EXPORT int fl_rmdir(const char *f);
|
||||
|
||||
/* OD: Portable UTF8 aware getenv wrapper */
|
||||
/* OD: Portable UTF-8 aware getenv wrapper */
|
||||
FL_EXPORT char* fl_getenv(const char *name);
|
||||
|
||||
/* OD: Portable UTF8 aware execvp wrapper */
|
||||
/* OD: Portable UTF-8 aware execvp wrapper */
|
||||
FL_EXPORT int fl_mkdir(const char* f, int mode);
|
||||
|
||||
/* OD: Portable UTF8 aware rename wrapper */
|
||||
/* OD: Portable UTF-8 aware rename wrapper */
|
||||
FL_EXPORT int fl_rename(const char* f, const char *t);
|
||||
|
||||
|
||||
|
|
|
@ -291,7 +291,6 @@ unsigned int fl_nonspacing(unsigned int ucs)
|
|||
<br>
|
||||
\par
|
||||
Returns true if \p ucs is a non-spacing character.
|
||||
<b>[What are non-spacing characters?]</b>
|
||||
|
||||
|
||||
const char* fl_utf8back(const char *p, const char *start, const char *end)
|
||||
|
|
|
@ -1296,7 +1296,7 @@ public:
|
|||
Fl_Process() {_fpt= NULL;}
|
||||
~Fl_Process() {if (_fpt) close();}
|
||||
|
||||
// FIXME: popen needs the utf8 equivalen fl_popen
|
||||
// FIXME: popen needs the UTF-8 equivalent fl_popen
|
||||
FILE * popen (const char *cmd, const char *mode="r");
|
||||
//not necessary here: FILE * fl_fopen (const char *file, const char *mode="r");
|
||||
int close();
|
||||
|
|
|
@ -350,7 +350,7 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp,
|
|||
if (w1 > W) W = w1;
|
||||
// calculate the maximum width of all shortcuts
|
||||
if (m->shortcut_) {
|
||||
// s is a pointerto the utf8 string for the entire shortcut
|
||||
// s is a pointer to the UTF-8 string for the entire shortcut
|
||||
// k points only to the key part (minus the modifier keys)
|
||||
const char *k, *s = fl_shortcut_label(m->shortcut_, &k);
|
||||
if (fl_utf_nb_char((const unsigned char*)k, (int) strlen(k))<=4) {
|
||||
|
|
22
src/fl_utf.c
22
src/fl_utf.c
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* This is the utf.c file from fltk2 adapted for use in my fltk1.1 port
|
||||
*/
|
||||
/* Copyright 2006-2011 by Bill Spitzak and others.
|
||||
/* Copyright 2006-2015 by Bill Spitzak and others.
|
||||
*
|
||||
* This library is free software. Distribution and use rights are outlined in
|
||||
* the file "COPYING" which should have been included with this file. If this
|
||||
|
@ -59,7 +59,7 @@
|
|||
/** @} */
|
||||
#endif /* 0 */
|
||||
|
||||
/*!Set to 1 to turn bad UTF8 bytes into ISO-8859-1. If this is to zero
|
||||
/*!Set to 1 to turn bad UTF-8 bytes into ISO-8859-1. If this is zero
|
||||
they are instead turned into the Unicode REPLACEMENT CHARACTER, of
|
||||
value 0xfffd.
|
||||
If this is on fl_utf8decode() will correctly map most (perhaps all)
|
||||
|
@ -69,7 +69,7 @@
|
|||
*/
|
||||
#define ERRORS_TO_ISO8859_1 1
|
||||
|
||||
/*!Set to 1 to turn bad UTF8 bytes in the 0x80-0x9f range into the
|
||||
/*!Set to 1 to turn bad UTF-8 bytes in the 0x80-0x9f range into the
|
||||
Unicode index for Microsoft's CP1252 character set. You should
|
||||
also set ERRORS_TO_ISO8859_1. With this a huge amount of more
|
||||
available text (such as all web pages) are correctly converted
|
||||
|
@ -118,7 +118,7 @@ static unsigned short cp1252[32] = {
|
|||
if (*p & 0x80) { // what should be a multibyte encoding
|
||||
code = fl_utf8decode(p,end,&len);
|
||||
if (len<2) code = 0xFFFD; // Turn errors into REPLACEMENT CHARACTER
|
||||
} else { // handle the 1-byte utf8 encoding:
|
||||
} else { // handle the 1-byte UTF-8 encoding:
|
||||
code = *p;
|
||||
len = 1;
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ unsigned fl_utf8decode(const char* p, const char* end, int* len)
|
|||
byte of the error is an individual character.
|
||||
|
||||
\e start is the start of the string and is used to limit the
|
||||
backwards search for the start of a utf8 character.
|
||||
backwards search for the start of a UTF-8 character.
|
||||
|
||||
\e end is the end of the string and is assumed to be a break
|
||||
between characters. It is assumed to be greater than p.
|
||||
|
@ -216,7 +216,7 @@ unsigned fl_utf8decode(const char* p, const char* end, int* len)
|
|||
This function is for moving a pointer that was jumped to the
|
||||
middle of a string, such as when doing a binary search for
|
||||
a position. You should use either this or fl_utf8back() depending
|
||||
on which direction your algorithim can handle the pointer
|
||||
on which direction your algorithm can handle the pointer
|
||||
moving. Do not use this to scan strings, use fl_utf8decode()
|
||||
instead.
|
||||
*/
|
||||
|
@ -532,12 +532,12 @@ unsigned fl_utf8towc(const char* src, unsigned srclen,
|
|||
If the UTF-8 decodes to a character greater than 0xff then it is
|
||||
replaced with '?'.
|
||||
|
||||
Errors in the UTF-8 are converted as individual bytes, same as
|
||||
Errors in the UTF-8 sequence are converted as individual bytes, same as
|
||||
fl_utf8decode() does. This allows ISO-8859-1 text mistakenly identified
|
||||
as UTF-8 to be printed correctly (and possibly CP1512 on Windows).
|
||||
as UTF-8 to be printed correctly (and possibly CP1252 on Windows).
|
||||
|
||||
\p src points at the UTF-8, and \p srclen is the number of bytes to
|
||||
convert.
|
||||
\p src points at the UTF-8 sequence, and \p srclen is the number of
|
||||
bytes to convert.
|
||||
|
||||
Up to \p dstlen bytes are written to \p dst, including a null
|
||||
terminator. The return value is the number of bytes that would be
|
||||
|
@ -629,7 +629,7 @@ unsigned fl_utf8fromwc(char* dst, unsigned dstlen,
|
|||
/* surrogate pair */
|
||||
unsigned ucs2 = src[i++];
|
||||
ucs = 0x10000U + ((ucs&0x3ff)<<10) + (ucs2&0x3ff);
|
||||
/* all surrogate pairs turn into 4-byte utf8 */
|
||||
/* all surrogate pairs turn into 4-byte UTF-8 */
|
||||
#else
|
||||
} else if (ucs >= 0x10000) {
|
||||
if (ucs > 0x10ffff) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* This file is required on all platforms for utf8 support
|
||||
* This file is required on all platforms for UTF-8 support
|
||||
*/
|
||||
|
||||
#include "headers/case.h"
|
||||
|
|
Loading…
Reference in New Issue