• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • kdecore
  • localization
guess_ja_p.h
Go to the documentation of this file.
1/*
2 * This file is part of the KDE libraries
3 *
4 * Copyright 2000-2003 Shiro Kawai <shiro@acm.org>, All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * 3. Neither the name of the authors nor the names of its contributors
18 * may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
27 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */
34/*
35 * original code is here.
36 * http://cvs.sourceforge.net/viewcvs.py/gauche/Gauche/ext/charconv/guess.c?view=markup
37 */
38#ifndef GUESS_JA_H
39#define GUESS_JA_H
40
41#include <qglobal.h>
42#ifdef Q_WS_WIN
43#undef UNICODE
44#endif
45#ifdef SOLARIS
46#undef UNICODE
47#endif
48namespace khtml {
49 class guess_arc {
50 public:
51 unsigned int next; /* next state */
52 double score; /* score */
53 };
54}
55
56using namespace khtml;
57
58typedef signed char dfa_table[256];
59
60/* DFA tables declared in guess_ja.cpp */
61extern const dfa_table guess_eucj_st[];
62extern guess_arc guess_eucj_ar[7];
63extern const dfa_table guess_sjis_st[];
64extern guess_arc guess_sjis_ar[6];
65extern const dfa_table guess_utf8_st[];
66extern guess_arc guess_utf8_ar[11];
67
68namespace khtml {
69
70 class guess_dfa {
71 public:
72 const dfa_table *states;
73 const guess_arc *arcs;
74 int state;
75 double score;
76
77 guess_dfa (const dfa_table stable[], const guess_arc *atable) :
78 states(stable), arcs(atable)
79 {
80 state = 0;
81 score = 1.0;
82 }
83 };
84
85 class JapaneseCode
86 {
87 public:
88 enum Type {ASCII, JIS, EUC, SJIS, UNICODE, UTF8 };
89 enum Type guess_jp(const char* buf, int buflen);
90
91 JapaneseCode () {
92 eucj = new guess_dfa(guess_eucj_st, guess_eucj_ar);
93 sjis = new guess_dfa(guess_sjis_st, guess_sjis_ar);
94 utf8 = new guess_dfa(guess_utf8_st, guess_utf8_ar);
95 last_JIS_escape = false;
96 }
97
98 ~JapaneseCode () {
99 delete eucj;
100 delete sjis;
101 delete utf8;
102 }
103
104 protected:
105 guess_dfa *eucj;
106 guess_dfa *sjis;
107 guess_dfa *utf8;
108
109 bool last_JIS_escape;
110 };
111}
112
113#define DFA_NEXT(dfa, ch) \
114 do { \
115 int arc__; \
116 if (dfa->state >= 0) { \
117 arc__ = dfa->states[dfa->state][ch]; \
118 if (arc__ < 0) { \
119 dfa->state = -1; \
120 } else { \
121 dfa->state = dfa->arcs[arc__].next; \
122 dfa->score *= dfa->arcs[arc__].score; \
123 } \
124 } \
125 } while (0)
126
127#define DFA_ALIVE(dfa) (dfa->state >= 0)
128
129#endif /* GUESS_JA_H */
khtml::JapaneseCode
Definition: guess_ja_p.h:86
khtml::JapaneseCode::Type
Type
Definition: guess_ja_p.h:88
khtml::JapaneseCode::UTF8
@ UTF8
Definition: guess_ja_p.h:88
khtml::JapaneseCode::JIS
@ JIS
Definition: guess_ja_p.h:88
khtml::JapaneseCode::EUC
@ EUC
Definition: guess_ja_p.h:88
khtml::JapaneseCode::ASCII
@ ASCII
Definition: guess_ja_p.h:88
khtml::JapaneseCode::UNICODE
@ UNICODE
Definition: guess_ja_p.h:88
khtml::JapaneseCode::SJIS
@ SJIS
Definition: guess_ja_p.h:88
khtml::JapaneseCode::eucj
guess_dfa * eucj
Definition: guess_ja_p.h:105
khtml::JapaneseCode::last_JIS_escape
bool last_JIS_escape
Definition: guess_ja_p.h:109
khtml::JapaneseCode::~JapaneseCode
~JapaneseCode()
Definition: guess_ja_p.h:98
khtml::JapaneseCode::JapaneseCode
JapaneseCode()
Definition: guess_ja_p.h:91
khtml::JapaneseCode::guess_jp
enum Type guess_jp(const char *buf, int buflen)
Definition: guess_ja.cpp:305
khtml::JapaneseCode::utf8
guess_dfa * utf8
Definition: guess_ja_p.h:107
khtml::JapaneseCode::sjis
guess_dfa * sjis
Definition: guess_ja_p.h:106
khtml::guess_arc
Definition: guess_ja_p.h:49
khtml::guess_arc::next
unsigned int next
Definition: guess_ja_p.h:51
khtml::guess_arc::score
double score
Definition: guess_ja_p.h:52
khtml::guess_dfa
Definition: guess_ja_p.h:70
khtml::guess_dfa::arcs
const guess_arc * arcs
Definition: guess_ja_p.h:73
khtml::guess_dfa::states
const dfa_table * states
Definition: guess_ja_p.h:72
khtml::guess_dfa::state
int state
Definition: guess_ja_p.h:74
khtml::guess_dfa::guess_dfa
guess_dfa(const dfa_table stable[], const guess_arc *atable)
Definition: guess_ja_p.h:77
khtml::guess_dfa::score
double score
Definition: guess_ja_p.h:75
guess_utf8_ar
guess_arc guess_utf8_ar[11]
Definition: guess_ja.cpp:290
guess_utf8_st
const dfa_table guess_utf8_st[]
Definition: guess_ja.cpp:179
guess_sjis_st
const dfa_table guess_sjis_st[]
Definition: guess_ja.cpp:131
guess_sjis_ar
guess_arc guess_sjis_ar[6]
Definition: guess_ja.cpp:170
guess_eucj_st
const dfa_table guess_eucj_st[]
Definition: guess_ja.cpp:46
guess_eucj_ar
guess_arc guess_eucj_ar[7]
Definition: guess_ja.cpp:121
guess_utf8_ar
guess_arc guess_utf8_ar[11]
Definition: guess_ja.cpp:290
dfa_table
signed char dfa_table[256]
Definition: guess_ja_p.h:58
guess_utf8_st
const dfa_table guess_utf8_st[]
Definition: guess_ja.cpp:179
guess_sjis_st
const dfa_table guess_sjis_st[]
Definition: guess_ja.cpp:131
guess_sjis_ar
guess_arc guess_sjis_ar[6]
Definition: guess_ja.cpp:170
guess_eucj_st
const dfa_table guess_eucj_st[]
Definition: guess_ja.cpp:46
guess_eucj_ar
guess_arc guess_eucj_ar[7]
Definition: guess_ja.cpp:121
khtml
Definition: guess_ja_p.h:48
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal