mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-22 06:21:45 +03:00
move utf8 local conversion operations to table
This commit is contained in:
parent
427f127fa9
commit
886a3106db
@ -16,10 +16,21 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <proto/iffparse.h>
|
||||
#include <proto/intuition.h>
|
||||
#include <proto/exec.h>
|
||||
#include <proto/datatypes.h>
|
||||
#include <proto/diskfont.h>
|
||||
|
||||
#include <diskfont/diskfonttag.h>
|
||||
#include <datatypes/textclass.h>
|
||||
#include <datatypes/pictureclass.h>
|
||||
|
||||
#include "utils/nsoption.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "desktop/gui.h"
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "utils/nsoption.h"
|
||||
|
||||
#include "amiga/bitmap.h"
|
||||
#include "amiga/clipboard.h"
|
||||
@ -31,18 +42,6 @@
|
||||
#include "amiga/menu.h"
|
||||
#include "amiga/utf8.h"
|
||||
|
||||
#include "utils/utf8.h"
|
||||
|
||||
#include <proto/iffparse.h>
|
||||
#include <proto/intuition.h>
|
||||
#include <proto/exec.h>
|
||||
#include <proto/datatypes.h>
|
||||
#include <proto/diskfont.h>
|
||||
|
||||
#include <diskfont/diskfonttag.h>
|
||||
#include <datatypes/textclass.h>
|
||||
#include <datatypes/pictureclass.h>
|
||||
|
||||
#define ID_UTF8 MAKE_ID('U','T','F','8')
|
||||
|
||||
struct IFFHandle *iffh = NULL;
|
||||
|
@ -5223,6 +5223,7 @@ int main(int argc, char** argv)
|
||||
.clipboard = amiga_clipboard_table,
|
||||
.download = amiga_download_table,
|
||||
.fetch = &amiga_fetch_table,
|
||||
.utf8 = amiga_utf8_table,
|
||||
};
|
||||
|
||||
/* Open popupmenu.library just to check the version.
|
||||
|
65
amiga/utf8.c
65
amiga/utf8.c
@ -18,13 +18,44 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "utils/utf8.h"
|
||||
#include "desktop/gui.h"
|
||||
#include <proto/exec.h>
|
||||
#include <proto/diskfont.h>
|
||||
#include <diskfont/diskfonttag.h>
|
||||
|
||||
#include "amiga/utf8.h"
|
||||
|
||||
nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
|
||||
{
|
||||
const char *encname = "ISO-8859-1";
|
||||
|
||||
#ifdef __amigaos4__
|
||||
LONG charset;
|
||||
|
||||
charset = GetDiskFontCtrl(DFCTRL_CHARSET);
|
||||
encname = (const char *) ObtainCharsetInfo(DFCS_NUMBER, charset, DFCS_MIMENAME);
|
||||
#endif
|
||||
|
||||
return utf8_from_enc(string,encname,len,result,NULL);
|
||||
}
|
||||
|
||||
nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
|
||||
{
|
||||
const char *encname = "ISO-8859-1";
|
||||
|
||||
#ifdef __amigaos4__
|
||||
LONG charset;
|
||||
|
||||
charset = GetDiskFontCtrl(DFCTRL_CHARSET);
|
||||
encname = (const char *) ObtainCharsetInfo(DFCS_NUMBER, charset, DFCS_MIMENAME);
|
||||
#endif
|
||||
|
||||
return utf8_to_enc(string,encname,len,result);
|
||||
}
|
||||
|
||||
void ami_utf8_free(char *ptr)
|
||||
{
|
||||
if(ptr) free(ptr);
|
||||
@ -58,32 +89,10 @@ char *ami_to_utf8_easy(const char *string)
|
||||
}
|
||||
}
|
||||
|
||||
nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
|
||||
{
|
||||
const char *encname = "ISO-8859-1";
|
||||
|
||||
#ifdef __amigaos4__
|
||||
LONG charset;
|
||||
|
||||
charset = GetDiskFontCtrl(DFCTRL_CHARSET);
|
||||
encname = (const char *) ObtainCharsetInfo(DFCS_NUMBER, charset, DFCS_MIMENAME);
|
||||
#endif
|
||||
|
||||
return utf8_from_enc(string,encname,len,result,NULL);
|
||||
}
|
||||
|
||||
nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
|
||||
{
|
||||
const char *encname = "ISO-8859-1";
|
||||
|
||||
#ifdef __amigaos4__
|
||||
LONG charset;
|
||||
|
||||
charset = GetDiskFontCtrl(DFCTRL_CHARSET);
|
||||
encname = (const char *) ObtainCharsetInfo(DFCS_NUMBER, charset, DFCS_MIMENAME);
|
||||
#endif
|
||||
|
||||
return utf8_to_enc(string,encname,len,result);
|
||||
}
|
||||
|
||||
static struct gui_utf8_table utf8_table = {
|
||||
.utf8_to_local = utf8_to_local_encoding,
|
||||
.local_to_utf8 = utf8_from_local_encoding,
|
||||
};
|
||||
|
||||
struct gui_utf8_table *amiga_utf8_table = &utf8_table;
|
||||
|
@ -18,7 +18,14 @@
|
||||
|
||||
#ifndef AMIGA_UTF8_H
|
||||
#define AMIGA_UTF8_H
|
||||
|
||||
extern struct gui_utf8_table *ami_utf8_table;
|
||||
|
||||
char *ami_utf8_easy(const char *string);
|
||||
void ami_utf8_free(char *ptr);
|
||||
char *ami_to_utf8_easy(const char *string);
|
||||
|
||||
nserror utf8_from_local_encoding(const char *string, size_t len, char **result);
|
||||
nserror utf8_to_local_encoding(const char *string, size_t len, char **result);
|
||||
|
||||
#endif
|
||||
|
@ -67,3 +67,9 @@ int atari_to_ucs4(unsigned char atari)
|
||||
}
|
||||
|
||||
|
||||
static struct gui_utf8_table utf8_table = {
|
||||
.utf8_to_local = utf8_to_local_encoding,
|
||||
.local_to_utf8 = utf8_from_local_encoding,
|
||||
};
|
||||
|
||||
struct gui_utf8_table *atari_utf8_table = &utf8_table;
|
||||
|
@ -1,32 +1,37 @@
|
||||
/*
|
||||
* Copyright 2012 Ole Loots <ole@monochrom.net>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/*
|
||||
* Copyright 2012 Ole Loots <ole@monochrom.net>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NS_ATARI_ENCODING_H
|
||||
#define NS_ATARI_ENCODING_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "css/css.h"
|
||||
#include "css/css.h"
|
||||
#include "render/font.h"
|
||||
#include "utils/utf8.h"
|
||||
|
||||
#include "utils/utf8.h"
|
||||
|
||||
struct gui_utf8_table *atari_utf8_table;
|
||||
|
||||
nserror utf8_to_local_encoding(const char *string, size_t len, char **result);
|
||||
nserror utf8_from_local_encoding(const char *string, size_t len, char **result);
|
||||
|
||||
int atari_to_ucs4( unsigned char atarichar);
|
||||
|
||||
#endif
|
||||
|
14
atari/gui.c
14
atari/gui.c
@ -30,6 +30,12 @@
|
||||
#include <stdbool.h>
|
||||
#include <hubbub/hubbub.h>
|
||||
|
||||
#include "utils/schedule.h"
|
||||
#include "utils/url.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "content/urldb.h"
|
||||
#include "content/fetch.h"
|
||||
#include "content/fetchers/resource.h"
|
||||
@ -38,8 +44,6 @@
|
||||
#include "desktop/local_history.h"
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/netsurf.h"
|
||||
|
||||
#include "utils/nsoption.h"
|
||||
#include "desktop/save_complete.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "desktop/treeview.h"
|
||||
@ -47,11 +51,6 @@
|
||||
#include "desktop/browser_private.h"
|
||||
#include "desktop/mouse.h"
|
||||
#include "render/font.h"
|
||||
#include "utils/schedule.h"
|
||||
#include "utils/url.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#include "atari/gemtk/gemtk.h"
|
||||
#include "atari/gui.h"
|
||||
@ -1113,6 +1112,7 @@ int main(int argc, char** argv)
|
||||
.clipboard = &atari_clipboard_table,
|
||||
.download = atari_download_table,
|
||||
.fetch = &atari_fetch_table,
|
||||
.utf8 = atari_utf8_table,
|
||||
};
|
||||
|
||||
/* @todo logging file descriptor update belongs in a nslog_init callback */
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
#include "atari/encoding.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include "desktop/textarea.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "atari/encoding.h"
|
||||
|
||||
|
||||
#define TB_BUTTON_WIDTH 32
|
||||
|
29
beos/gui.cpp
29
beos/gui.cpp
@ -963,35 +963,6 @@ static void nsbeos_create_ssl_verify_window(struct browser_window *bw,
|
||||
CALLED();
|
||||
}
|
||||
|
||||
|
||||
nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
|
||||
{
|
||||
assert(string && result);
|
||||
|
||||
if (len == 0)
|
||||
len = strlen(string);
|
||||
|
||||
*result = strndup(string, len);
|
||||
if (!(*result))
|
||||
return NSERROR_NOMEM;
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
|
||||
{
|
||||
assert(string && result);
|
||||
|
||||
if (len == 0)
|
||||
len = strlen(string);
|
||||
|
||||
*result = strndup(string, len);
|
||||
if (!(*result))
|
||||
return NSERROR_NOMEM;
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
static char *path_to_url(const char *path)
|
||||
{
|
||||
int urllen = strlen(path) + FILE_SCHEME_PREFIX_LEN + 1;
|
||||
|
@ -95,7 +95,6 @@ S_COCOA := \
|
||||
schedule.m \
|
||||
selection.m \
|
||||
thumbnail.m \
|
||||
utf8.m \
|
||||
utils.m \
|
||||
ArrowBox.m \
|
||||
ArrowWindow.m \
|
||||
|
40
cocoa/utf8.m
40
cocoa/utf8.m
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "utils/utf8.h"
|
||||
|
||||
nserror utf8_to_local_encoding(const char *string, size_t len,
|
||||
char **result)
|
||||
{
|
||||
NSCParameterAssert( NULL != result );
|
||||
|
||||
char *newString = malloc( len + 1 );
|
||||
if (NULL == newString) return NSERROR_NOMEM;
|
||||
memcpy( newString, string, len );
|
||||
newString[len] = 0;
|
||||
*result = newString;
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
|
||||
{
|
||||
/* same function, local encoding = UTF-8 */
|
||||
return utf8_to_local_encoding( string, len, result );
|
||||
}
|
@ -272,6 +272,11 @@ static void gui_default_set_clipboard(const char *buffer, size_t length,
|
||||
{
|
||||
}
|
||||
|
||||
static struct gui_clipboard_table default_clipboard_table = {
|
||||
.get = gui_default_get_clipboard,
|
||||
.set = gui_default_set_clipboard,
|
||||
};
|
||||
|
||||
/** verify clipboard table is valid */
|
||||
static nserror verify_clipboard_register(struct gui_clipboard_table *gct)
|
||||
{
|
||||
@ -290,6 +295,54 @@ static nserror verify_clipboard_register(struct gui_clipboard_table *gct)
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default utf8 conversion implementation.
|
||||
*
|
||||
* The default implementation assumes the local encoding is utf8
|
||||
* allowing the conversion to be a simple copy.
|
||||
*
|
||||
* @param [in] string The source string.
|
||||
* @param [in] len The \a string length or 0 to compute it.
|
||||
* @param [out] result A pointer to the converted string.
|
||||
* @result NSERROR_OK or NSERROR_NOMEM if memory could not be allocated.
|
||||
*/
|
||||
static nserror gui_default_utf8(const char *string, size_t len, char **result)
|
||||
{
|
||||
assert(string && result);
|
||||
|
||||
if (len == 0)
|
||||
len = strlen(string);
|
||||
|
||||
*result = strndup(string, len);
|
||||
if (!(*result))
|
||||
return NSERROR_NOMEM;
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
static struct gui_utf8_table default_utf8_table = {
|
||||
.utf8_to_local = gui_default_utf8,
|
||||
.local_to_utf8 = gui_default_utf8,
|
||||
};
|
||||
|
||||
/** verify clipboard table is valid */
|
||||
static nserror verify_utf8_register(struct gui_utf8_table *gut)
|
||||
{
|
||||
/* check table is present */
|
||||
if (gut == NULL) {
|
||||
return NSERROR_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
/* mandantory operations */
|
||||
if (gut->utf8_to_local == NULL) {
|
||||
return NSERROR_BAD_PARAMETER;
|
||||
}
|
||||
if (gut->local_to_utf8 == NULL) {
|
||||
return NSERROR_BAD_PARAMETER;
|
||||
}
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
static nsurl *gui_default_get_resource_url(const char *path)
|
||||
{
|
||||
return NULL;
|
||||
@ -370,6 +423,13 @@ static void gui_default_401login_open(nsurl *url, const char *realm,
|
||||
cb(false, cbpw);
|
||||
}
|
||||
|
||||
static struct gui_download_table default_download_table = {
|
||||
.create = gui_default_download_create,
|
||||
.data = gui_default_download_data,
|
||||
.error = gui_default_download_error,
|
||||
.done = gui_default_download_done,
|
||||
};
|
||||
|
||||
/** verify browser table is valid */
|
||||
static nserror verify_browser_register(struct gui_browser_table *gbt)
|
||||
{
|
||||
@ -406,19 +466,6 @@ static nserror verify_browser_register(struct gui_browser_table *gbt)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct gui_download_table default_download_table = {
|
||||
.create = gui_default_download_create,
|
||||
.data = gui_default_download_data,
|
||||
.error = gui_default_download_error,
|
||||
.done = gui_default_download_done,
|
||||
};
|
||||
|
||||
static struct gui_clipboard_table default_clipboard_table = {
|
||||
.get = gui_default_get_clipboard,
|
||||
.set = gui_default_set_clipboard,
|
||||
};
|
||||
|
||||
/* exported interface documented in desktop/gui_factory.h */
|
||||
nserror gui_factory_register(struct gui_table *gt)
|
||||
{
|
||||
@ -472,6 +519,16 @@ nserror gui_factory_register(struct gui_table *gt)
|
||||
return err;
|
||||
}
|
||||
|
||||
/* utf8 table */
|
||||
if (gt->utf8 == NULL) {
|
||||
/* set default clipboard table */
|
||||
gt->utf8 = &default_utf8_table;
|
||||
}
|
||||
err = verify_utf8_register(gt->utf8);
|
||||
if (err != NSERROR_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
guit = gt;
|
||||
|
||||
return NSERROR_OK;
|
||||
|
@ -28,14 +28,16 @@
|
||||
#include <dom/dom.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
#include "content/content.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "desktop/save_text.h"
|
||||
#include "render/box.h"
|
||||
#include "render/html.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
#include "content/content.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "render/box.h"
|
||||
#include "render/html.h"
|
||||
|
||||
#include "desktop/gui_factory.h"
|
||||
#include "desktop/save_text.h"
|
||||
|
||||
static void extract_text(struct box *box, bool *first,
|
||||
save_text_whitespace *before, struct save_text_state *save);
|
||||
@ -69,7 +71,7 @@ void save_as_text(hlcache_handle *c, char *path)
|
||||
if (!save.block)
|
||||
return;
|
||||
|
||||
ret = utf8_to_local_encoding(save.block, save.length, &result);
|
||||
ret = guit->utf8->utf8_to_local(save.block, save.length, &result);
|
||||
free(save.block);
|
||||
|
||||
if (ret != NSERROR_OK) {
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include "utils/utf8.h"
|
||||
|
||||
extern struct gui_utf8_table *framebuffer_utf8_table;
|
||||
|
||||
bool fb_font_init(void);
|
||||
bool fb_font_finalise(void);
|
||||
|
||||
|
@ -23,13 +23,14 @@
|
||||
#include <ft2build.h>
|
||||
#include FT_CACHE_H
|
||||
|
||||
#include "css/css.h"
|
||||
#include "css/utils.h"
|
||||
#include "render/font.h"
|
||||
#include "utils/filepath.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "css/css.h"
|
||||
#include "css/utils.h"
|
||||
#include "render/font.h"
|
||||
#include "desktop/gui.h"
|
||||
|
||||
#include "framebuffer/gui.h"
|
||||
#include "framebuffer/font.h"
|
||||
@ -74,30 +75,6 @@ enum fb_face_e {
|
||||
|
||||
static fb_faceid_t *fb_faces[FB_FACE_COUNT];
|
||||
|
||||
|
||||
nserror utf8_to_local_encoding(const char *string,
|
||||
size_t len,
|
||||
char **result)
|
||||
{
|
||||
return utf8_to_enc(string, "UTF-8", len, result);
|
||||
}
|
||||
|
||||
nserror utf8_from_local_encoding(const char *string,
|
||||
size_t len,
|
||||
char **result)
|
||||
{
|
||||
*result = malloc(len + 1);
|
||||
if (*result == NULL) {
|
||||
return NSERROR_NOMEM;
|
||||
}
|
||||
|
||||
memcpy(*result, string, len);
|
||||
|
||||
(*result)[len] = '\0';
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/* map cache manager handle to face id */
|
||||
static FT_Error ft_face_requester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *face )
|
||||
{
|
||||
@ -581,6 +558,8 @@ const struct font_functions nsfont = {
|
||||
nsfont_split
|
||||
};
|
||||
|
||||
struct gui_utf8_table *framebuffer_utf8_table = NULL;
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* c-basic-offset:8
|
||||
|
@ -19,12 +19,13 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include "css/css.h"
|
||||
#include "render/font.h"
|
||||
|
||||
#include "utils/nsoption.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "desktop/gui.h"
|
||||
#include "css/css.h"
|
||||
#include "render/font.h"
|
||||
|
||||
#include "framebuffer/gui.h"
|
||||
#include "framebuffer/font.h"
|
||||
@ -68,7 +69,7 @@ nserror utf8_to_font_encoding(const struct fb_font_desc* font,
|
||||
|
||||
}
|
||||
|
||||
nserror utf8_to_local_encoding(const char *string,
|
||||
static nserror utf8_to_local(const char *string,
|
||||
size_t len,
|
||||
char **result)
|
||||
{
|
||||
@ -76,7 +77,7 @@ nserror utf8_to_local_encoding(const char *string,
|
||||
|
||||
}
|
||||
|
||||
nserror utf8_from_local_encoding(const char *string,
|
||||
static nserror utf8_from_local(const char *string,
|
||||
size_t len,
|
||||
char **result)
|
||||
{
|
||||
@ -183,6 +184,14 @@ const struct font_functions nsfont = {
|
||||
nsfont_split
|
||||
};
|
||||
|
||||
static struct gui_utf8_table utf8_table = {
|
||||
.utf8_to_local = utf8_to_local,
|
||||
.local_to_utf8 = utf8_from_local,
|
||||
};
|
||||
|
||||
struct gui_utf8_table *framebuffer_utf8_table = &utf8_table;
|
||||
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* c-basic-offset:8
|
||||
|
@ -1815,6 +1815,7 @@ main(int argc, char** argv)
|
||||
.window = &framebuffer_window_table,
|
||||
.clipboard = framebuffer_clipboard_table,
|
||||
.fetch = framebuffer_fetch_table,
|
||||
.utf8 = framebuffer_utf8_table,
|
||||
};
|
||||
|
||||
respaths = fb_init_resource(NETSURF_FB_RESPATH":"NETSURF_FB_FONTPATH);
|
||||
|
31
gtk/gui.c
31
gtk/gui.c
@ -788,37 +788,6 @@ gboolean nsgtk_ssl_delete_event(GtkWidget *w, GdkEvent *event, gpointer data)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
|
||||
{
|
||||
assert(string && result);
|
||||
|
||||
if (len == 0)
|
||||
len = strlen(string);
|
||||
|
||||
*result = strndup(string, len);
|
||||
if (!(*result))
|
||||
return NSERROR_NOMEM;
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
|
||||
{
|
||||
assert(string && result);
|
||||
|
||||
if (len == 0)
|
||||
len = strlen(string);
|
||||
|
||||
*result = strndup(string, len);
|
||||
if (!(*result))
|
||||
return NSERROR_NOMEM;
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef WITH_PDF_EXPORT
|
||||
|
||||
void PDF_Password(char **owner_pass, char **user_pass, char *path)
|
||||
|
@ -22,10 +22,6 @@
|
||||
|
||||
#include "utils/config.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/url.h"
|
||||
#include "utils/utf8.h"
|
||||
|
||||
|
||||
|
||||
void warn_user(const char *warning, const char *detail)
|
||||
{
|
||||
@ -37,17 +33,3 @@ void die(const char * const error)
|
||||
fprintf(stderr, "DIE %s\n", error);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
|
||||
{
|
||||
*result = strndup(string, len);
|
||||
return (*result == NULL) ? NSERROR_NOMEM : NSERROR_OK;
|
||||
}
|
||||
|
||||
nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
|
||||
{
|
||||
*result = strndup(string, len);
|
||||
return (*result == NULL) ? NSERROR_NOMEM : NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,22 +29,6 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
#include "content/content_protected.h"
|
||||
#include "content/fetch.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "desktop/selection.h"
|
||||
#include "desktop/scrollbar.h"
|
||||
#include "desktop/textarea.h"
|
||||
#include "image/bitmap.h"
|
||||
#include "render/box.h"
|
||||
#include "render/font.h"
|
||||
#include "render/form.h"
|
||||
#include "render/html_internal.h"
|
||||
#include "render/imagemap.h"
|
||||
#include "render/layout.h"
|
||||
#include "render/search.h"
|
||||
#include "javascript/js.h"
|
||||
#include "utils/corestrings.h"
|
||||
#include "utils/http.h"
|
||||
#include "utils/libdom.h"
|
||||
@ -55,6 +39,24 @@
|
||||
#include "utils/url.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "content/content_protected.h"
|
||||
#include "content/fetch.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "desktop/selection.h"
|
||||
#include "desktop/scrollbar.h"
|
||||
#include "desktop/textarea.h"
|
||||
#include "image/bitmap.h"
|
||||
#include "javascript/js.h"
|
||||
#include "desktop/gui_factory.h"
|
||||
|
||||
#include "render/box.h"
|
||||
#include "render/font.h"
|
||||
#include "render/form.h"
|
||||
#include "render/html_internal.h"
|
||||
#include "render/imagemap.h"
|
||||
#include "render/layout.h"
|
||||
#include "render/search.h"
|
||||
|
||||
#define CHUNK 4096
|
||||
|
||||
@ -1770,10 +1772,10 @@ static void html__set_file_gadget_filename(struct content *c,
|
||||
html_content *html = (html_content *)c;
|
||||
struct box *file_box = gadget->box;
|
||||
|
||||
ret = utf8_from_local_encoding(fn,0, &utf8_fn);
|
||||
ret = guit->utf8->local_to_utf8(fn,0, &utf8_fn);
|
||||
if (ret != NSERROR_OK) {
|
||||
assert(ret != NSERROR_BAD_ENCODING);
|
||||
LOG(("utf8_from_local_encoding failed"));
|
||||
LOG(("utf8 to local encoding conversion failed"));
|
||||
/* Load was for us - just no memory */
|
||||
return;
|
||||
}
|
||||
@ -1915,11 +1917,11 @@ static bool html_drop_file_at_point(struct content *c, int x, int y, char *file)
|
||||
/* TODO: Sniff for text? */
|
||||
|
||||
/* Convert to UTF-8 */
|
||||
ret = utf8_from_local_encoding(buffer, file_len, &utf8_buff);
|
||||
ret = guit->utf8->local_to_utf8(buffer, file_len, &utf8_buff);
|
||||
if (ret != NSERROR_OK) {
|
||||
/* bad encoding shouldn't happen */
|
||||
assert(ret != NSERROR_BAD_ENCODING);
|
||||
LOG(("utf8_from_local_encoding failed"));
|
||||
LOG(("local to utf8 encoding failed"));
|
||||
free(buffer);
|
||||
warn_user("NoMemory", NULL);
|
||||
return true;
|
||||
|
@ -58,6 +58,7 @@
|
||||
#include "utils/url.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
#include "riscos/ucstables.h"
|
||||
|
||||
#define ICON_DOWNLOAD_ICON 0
|
||||
#define ICON_DOWNLOAD_URL 1
|
||||
|
@ -99,7 +99,7 @@
|
||||
#include "riscos/wimp_event.h"
|
||||
#include "riscos/wimputils.h"
|
||||
#include "riscos/window.h"
|
||||
|
||||
#include "riscos/ucstables.h"
|
||||
|
||||
|
||||
#ifndef FILETYPE_ACORN_URI
|
||||
@ -2389,6 +2389,7 @@ int main(int argc, char** argv)
|
||||
.clipboard = riscos_clipboard_table,
|
||||
.download = riscos_download_table,
|
||||
.fetch = &riscos_fetch_table,
|
||||
.utf8 = riscos_utf8_table,
|
||||
};
|
||||
|
||||
/* Consult NetSurf$Logging environment variable to decide if logging
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
#include "riscos/ucstables.h"
|
||||
|
||||
#define URLBAR_HEIGHT 52
|
||||
#define URLBAR_FAVICON_SIZE 16
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "utils/log.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
#include "riscos/ucstables.h"
|
||||
|
||||
|
||||
/* Recognised help keys
|
||||
|
@ -31,6 +31,12 @@
|
||||
#include "oslib/osgbpb.h"
|
||||
#include "oslib/territory.h"
|
||||
#include "oslib/wimp.h"
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/url.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "content/content.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "content/urldb.h"
|
||||
@ -40,6 +46,7 @@
|
||||
#include "desktop/local_history.h"
|
||||
#include "desktop/netsurf.h"
|
||||
#include "desktop/textinput.h"
|
||||
|
||||
#include "riscos/dialog.h"
|
||||
#include "riscos/configure.h"
|
||||
#include "riscos/cookies.h"
|
||||
@ -56,11 +63,7 @@
|
||||
#include "riscos/url_suggest.h"
|
||||
#include "riscos/wimp.h"
|
||||
#include "riscos/wimp_event.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/url.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "riscos/ucstables.h"
|
||||
|
||||
struct menu_definition_entry {
|
||||
menu_action action; /**< menu action */
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
#include "riscos/ucstables.h"
|
||||
|
||||
#define ICON_QUERY_MESSAGE 0
|
||||
#define ICON_QUERY_YES 1
|
||||
|
@ -69,6 +69,7 @@
|
||||
#include "riscos/thumbnail.h"
|
||||
#include "riscos/wimp.h"
|
||||
#include "riscos/wimp_event.h"
|
||||
#include "riscos/ucstables.h"
|
||||
|
||||
//typedef enum
|
||||
//{
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "riscos/mouse.h"
|
||||
#include "riscos/save.h"
|
||||
#include "riscos/textselection.h"
|
||||
#include "riscos/ucstables.h"
|
||||
|
||||
|
||||
#ifndef wimp_DRAG_CLAIM_SUPPRESS_DRAGBOX
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "utils/log.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
#include "desktop/gui.h"
|
||||
|
||||
/* Common values (ASCII) */
|
||||
#define common \
|
||||
@ -684,3 +685,10 @@ nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
static struct gui_utf8_table utf8_table = {
|
||||
.utf8_to_local = utf8_to_local_encoding,
|
||||
.local_to_utf8 = utf8_from_local_encoding,
|
||||
};
|
||||
|
||||
struct gui_utf8_table *riscos_utf8_table = &utf8_table;
|
||||
|
@ -21,4 +21,9 @@
|
||||
* This is only used if nothing claims Service_International,8
|
||||
*/
|
||||
|
||||
struct gui_utf8_table *riscos_utf8_table;
|
||||
|
||||
nserror utf8_to_local_encoding(const char *string, size_t len, char **result);
|
||||
nserror utf8_from_local_encoding(const char *string, size_t len, char **result);
|
||||
|
||||
const int *ucstable_from_alphabet(int alphabet);
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "utils/log.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
#include "riscos/ucstables.h"
|
||||
|
||||
|
||||
static void ro_gui_wimp_cache_furniture_sizes(wimp_w w);
|
||||
|
@ -90,6 +90,7 @@
|
||||
#include "riscos/wimp_event.h"
|
||||
#include "riscos/wimputils.h"
|
||||
#include "riscos/window.h"
|
||||
#include "riscos/ucstables.h"
|
||||
|
||||
void gui_window_redraw_window(struct gui_window *g);
|
||||
|
||||
|
@ -29,6 +29,8 @@
|
||||
|
||||
#include <parserutils/charset/utf8.h>
|
||||
|
||||
#include "desktop/gui_factory.h"
|
||||
|
||||
#include "utils/config.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utf8.h"
|
||||
@ -463,8 +465,7 @@ bool utf8_save_text(const char *utf8_text, const char *path)
|
||||
char *conv;
|
||||
FILE *out;
|
||||
|
||||
ret = utf8_to_local_encoding(utf8_text, strlen(utf8_text), &conv);
|
||||
|
||||
ret = guit->utf8->utf8_to_local(utf8_text, strlen(utf8_text), &conv);
|
||||
if (ret != NSERROR_OK) {
|
||||
LOG(("failed to convert to local encoding, return %d", ret));
|
||||
return false;
|
||||
|
@ -161,9 +161,4 @@ bool utf8_save_text(const char *utf8_text, const char *path);
|
||||
*/
|
||||
nserror utf8_finalise(void);
|
||||
|
||||
/* These two are platform specific */
|
||||
nserror utf8_to_local_encoding(const char *string, size_t len, char **result);
|
||||
nserror utf8_from_local_encoding(const char *string, size_t len, char **result);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -43,14 +43,14 @@ nserror utf8_to_font_encoding(const struct font_desc* font,
|
||||
return utf8_to_enc(string, font->encoding, len, result);
|
||||
}
|
||||
|
||||
nserror utf8_to_local_encoding(const char *string,
|
||||
static nserror utf8_to_local_encoding(const char *string,
|
||||
size_t len,
|
||||
char **result)
|
||||
{
|
||||
return utf8_to_enc(string, "UCS-2", len, result);
|
||||
}
|
||||
|
||||
nserror utf8_from_local_encoding(const char *string, size_t len,
|
||||
static nserror utf8_from_local_encoding(const char *string, size_t len,
|
||||
char **result)
|
||||
{
|
||||
assert(string && result);
|
||||
@ -234,3 +234,10 @@ const struct font_functions nsfont = {
|
||||
nsfont_position_in_string,
|
||||
nsfont_split
|
||||
};
|
||||
|
||||
static struct gui_utf8_table utf8_table = {
|
||||
.utf8_to_local = utf8_to_local_encoding,
|
||||
.local_to_utf8 = utf8_from_local_encoding,
|
||||
};
|
||||
|
||||
struct gui_utf8_table *win32_utf8_table = &utf8_table;
|
||||
|
@ -28,6 +28,7 @@ extern struct gui_window_table *win32_window_table;
|
||||
extern struct gui_clipboard_table *win32_clipboard_table;
|
||||
extern struct gui_fetch_table *win32_fetch_table;
|
||||
extern struct gui_browser_table *win32_browser_table;
|
||||
extern struct gui_utf8_table *win32_utf8_table;
|
||||
|
||||
extern HINSTANCE hInstance;
|
||||
|
||||
|
@ -111,6 +111,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
|
||||
.clipboard = win32_clipboard_table,
|
||||
.download = win32_download_table,
|
||||
.fetch = win32_fetch_table,
|
||||
.utf8 = win32_utf8_table,
|
||||
};
|
||||
win32_fetch_table->get_resource_url = gui_get_resource_url;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user