[gnome-subtitles] Merging the SubLib project with Gnome Subtitles
- From: Pedro Daniel da Rocha Melo e Castro <pcastro src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-subtitles] Merging the SubLib project with Gnome Subtitles
- Date: Wed, 3 Jun 2009 19:22:05 -0400 (EDT)
commit ddcea92999a628964fda4e2755777f280a9cac0a
Author: Pedro Castro <mail pedrocastro org>
Date: Thu Jun 4 00:20:49 2009 +0100
Merging the SubLib project with Gnome Subtitles
---
configure.ac | 5 -
gnome-subtitles.mdp | 93 +-
src/External/NCharDet/Big5Statistics.cs | 269 +++
src/External/NCharDet/COPYING-MPL | 470 +++++
src/External/NCharDet/EUCJPStatistics.cs | 272 +++
src/External/NCharDet/EUCKRStatistics.cs | 272 +++
src/External/NCharDet/EUCTWStatistics.cs | 270 +++
src/External/NCharDet/GB2312Statistics.cs | 273 +++
src/External/NCharDet/nsBIG5Verifier.cs | 116 ++
src/External/NCharDet/nsCP1252Verifier.cs | 116 ++
src/External/NCharDet/nsDetector.cs | 93 +
src/External/NCharDet/nsEUCJPVerifier.cs | 118 ++
src/External/NCharDet/nsEUCKRVerifier.cs | 116 ++
src/External/NCharDet/nsEUCSampler.cs | 147 ++
src/External/NCharDet/nsEUCStatistics.cs | 59 +
src/External/NCharDet/nsEUCTWVerifier.cs | 119 ++
src/External/NCharDet/nsGB18030Verifier.cs | 119 ++
src/External/NCharDet/nsGB2312Verifier.cs | 116 ++
src/External/NCharDet/nsHZVerifier.cs | 120 ++
.../NCharDet/nsICharsetDetectionObserver.cs | 48 +
src/External/NCharDet/nsICharsetDetector.cs | 49 +
src/External/NCharDet/nsISO2022CNVerifier.cs | 121 ++
src/External/NCharDet/nsISO2022JPVerifier.cs | 119 ++
src/External/NCharDet/nsISO2022KRVerifier.cs | 119 ++
src/External/NCharDet/nsPSMDetector.cs | 428 ++++
src/External/NCharDet/nsSJISVerifier.cs | 116 ++
src/External/NCharDet/nsUCS2BEVerifier.cs | 120 ++
src/External/NCharDet/nsUCS2LEVerifier.cs | 120 ++
src/External/NCharDet/nsUTF8Verifier.cs | 140 ++
src/External/NCharDet/nsVerifier.cs | 81 +
src/Glade/AboutDialog.glade | 1 +
src/GnomeSubtitles/Dialog/AboutDialog.cs | 2 -
src/GnomeSubtitles/Execution/BugReporter.cs | 1 -
src/GnomeSubtitles/Execution/ExecutionContext.cs | 24 +-
src/Makefile.am | 12 +-
src/SubLib/ChangeLog | 2084 ++++++++++++++++++++
src/SubLib/Core/Domain/Enumerations.cs | 147 ++
src/SubLib/Core/Domain/FileProperties.cs | 129 ++
src/SubLib/Core/Domain/Frames.cs | 116 ++
src/SubLib/Core/Domain/Headers.cs | 326 +++
src/SubLib/Core/Domain/IncompleteSubtitle.cs | 58 +
.../Core/Domain/IncompleteSubtitleCollection.cs | 70 +
src/SubLib/Core/Domain/Style.cs | 82 +
src/SubLib/Core/Domain/Subtitle.cs | 181 ++
src/SubLib/Core/Domain/SubtitleCollection.cs | 168 ++
src/SubLib/Core/Domain/SubtitleConstants.cs | 95 +
src/SubLib/Core/Domain/SubtitleHeaders.cs | 536 +++++
src/SubLib/Core/Domain/SubtitleProperties.cs | 90 +
src/SubLib/Core/Domain/SubtitleText.cs | 195 ++
src/SubLib/Core/Domain/SubtitleTypeInfo.cs | 118 ++
src/SubLib/Core/Domain/Subtitles.cs | 114 ++
src/SubLib/Core/Domain/SyncPoint.cs | 56 +
src/SubLib/Core/Domain/SyncPoints.cs | 84 +
src/SubLib/Core/Domain/Times.cs | 131 ++
src/SubLib/Core/Domain/Timing.cs | 52 +
src/SubLib/Core/MatchEvaluationCounter.cs | 51 +
src/SubLib/Core/Search/SearchOperator.cs | 311 +++
src/SubLib/Core/Search/SubtitleSearchOptions.cs | 109 +
src/SubLib/Core/Search/SubtitleSearchResults.cs | 68 +
src/SubLib/Core/SubtitleFactory.cs | 213 ++
src/SubLib/Core/SubtitleSaver.cs | 71 +
src/SubLib/Core/Timing/AdjustOperator.cs | 85 +
src/SubLib/Core/Timing/FrameRateOperator.cs | 67 +
src/SubLib/Core/Timing/ShiftOperator.cs | 96 +
src/SubLib/Core/Timing/SyncUtil.cs | 134 ++
src/SubLib/Core/Timing/SynchronizeOperator.cs | 101 +
src/SubLib/Core/Timing/TimingUtil.cs | 67 +
src/SubLib/Core/Translations.cs | 78 +
.../Exceptions/EncodingNotSupportedException.cs | 36 +
src/SubLib/Exceptions/UnknownEncodingException.cs | 36 +
.../Exceptions/UnknownSubtitleFormatException.cs | 36 +
src/SubLib/IO/FileInputOutput.cs | 164 ++
src/SubLib/IO/Input/ParsingProperties.cs | 45 +
src/SubLib/IO/Input/PlainTextParser.cs | 91 +
src/SubLib/IO/Input/SubtitleInput.cs | 211 ++
src/SubLib/IO/Input/SubtitleParser.cs | 576 ++++++
src/SubLib/IO/Output/SubtitleOutput.cs | 229 +++
src/SubLib/IO/Output/VerboseConsole.cs | 44 +
.../IO/SubtitleFormats/BuiltInSubtitleFormats.cs | 84 +
src/SubLib/IO/SubtitleFormats/SubtitleFormat.cs | 194 ++
.../IO/SubtitleFormats/SubtitleFormatAQTitle.cs | 72 +
.../SubtitleFormatAdobeEncoreDVD.cs | 74 +
.../SubtitleFormatAdvancedSubStationAlpha.cs | 65 +
.../SubtitleFormatDKSSubtitleFormat.cs | 46 +
.../SubtitleFormatKaraokeLyricsLRC.cs | 68 +
.../SubtitleFormatKaraokeLyricsVKT.cs | 66 +
.../IO/SubtitleFormats/SubtitleFormatMPSub.cs | 68 +
.../IO/SubtitleFormats/SubtitleFormatMPlayer.cs | 43 +
.../IO/SubtitleFormats/SubtitleFormatMPlayer2.cs | 42 +
.../IO/SubtitleFormats/SubtitleFormatMacSUB.cs | 46 +
.../IO/SubtitleFormats/SubtitleFormatMicroDVD.cs | 74 +
.../IO/SubtitleFormats/SubtitleFormatPanimator.cs | 47 +
.../SubtitleFormatPhoenixJapanimationSociety.cs | 46 +
.../IO/SubtitleFormats/SubtitleFormatPowerDivX.cs | 45 +
.../IO/SubtitleFormats/SubtitleFormatSofni.cs | 46 +
.../SubtitleFormats/SubtitleFormatSubCreator1x.cs | 45 +
.../IO/SubtitleFormats/SubtitleFormatSubRip.cs | 83 +
.../SubtitleFormatSubStationAlpha.cs | 172 ++
.../IO/SubtitleFormats/SubtitleFormatSubViewer1.cs | 72 +
.../IO/SubtitleFormats/SubtitleFormatSubViewer2.cs | 76 +
.../SubtitleFormatViPlaySubtitleFile.cs | 74 +
101 files changed, 14036 insertions(+), 27 deletions(-)
diff --git a/configure.ac b/configure.ac
index aec6e41..aa32142 100644
--- a/configure.ac
+++ b/configure.ac
@@ -78,12 +78,7 @@ if test "x$gtksharp_invalid" = "xtrue"; then
AC_MSG_ERROR([gtk-sharp versions between 2.12.2 and 2.12.6 (inclusive) are not supported.])
fi
-dnl SubLib
-SUBLIB_REQUIRED_VERSION=0.9
-PKG_CHECK_MODULES(SUBLIB, sublib >= $SUBLIB_REQUIRED_VERSION)
PKG_PROG_PKG_CONFIG()
-SUBLIB_DLL_DIR="`$PKG_CONFIG --variable=libdir sublib`/sublib"
-AC_SUBST(SUBLIB_DLL_DIR)
AC_SUBST(MCS)
diff --git a/gnome-subtitles.mdp b/gnome-subtitles.mdp
index d7cb739..52950df 100644
--- a/gnome-subtitles.mdp
+++ b/gnome-subtitles.mdp
@@ -150,6 +150,98 @@
<File name="src/GnomeSubtitles/Dialog/Unmanaged/WarningDialog.cs" subtype="Code" buildaction="Compile" />
<File name="src/GnomeSubtitles/Dialog/SetTextLanguageDialog.cs" subtype="Code" buildaction="Compile" />
<File name="src/GnomeSubtitles/Dialog/SetTranslationLanguageDialog.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/Big5Statistics.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/EUCJPStatistics.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/EUCKRStatistics.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/EUCTWStatistics.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/GB2312Statistics.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsBIG5Verifier.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsCP1252Verifier.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsDetector.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsEUCJPVerifier.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsEUCKRVerifier.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsEUCSampler.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsEUCStatistics.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsEUCTWVerifier.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsGB2312Verifier.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsGB18030Verifier.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsHZVerifier.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsICharsetDetectionObserver.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsICharsetDetector.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsISO2022CNVerifier.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsISO2022JPVerifier.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsISO2022KRVerifier.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsPSMDetector.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsSJISVerifier.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsUCS2BEVerifier.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsUCS2LEVerifier.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsUTF8Verifier.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/External/NCharDet/nsVerifier.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/Enumerations.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/FileProperties.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/Frames.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/Headers.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/IncompleteSubtitle.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/IncompleteSubtitleCollection.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/Style.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/Subtitle.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/SubtitleCollection.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/SubtitleConstants.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/SubtitleHeaders.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/SubtitleProperties.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/Subtitles.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/SubtitleText.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/SubtitleTypeInfo.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/SyncPoint.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/SyncPoints.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/Times.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Domain/Timing.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Search/SearchOperator.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Search/SubtitleSearchOptions.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Search/SubtitleSearchResults.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Timing/AdjustOperator.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Timing/FrameRateOperator.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Timing/ShiftOperator.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Timing/SynchronizeOperator.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Timing/SyncUtil.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Timing/TimingUtil.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/MatchEvaluationCounter.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/SubtitleFactory.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/SubtitleSaver.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Core/Translations.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Exceptions/EncodingNotSupportedException.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Exceptions/UnknownEncodingException.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/Exceptions/UnknownSubtitleFormatException.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/FileInputOutput.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/Input/ParsingProperties.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/Input/PlainTextParser.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/Input/SubtitleInput.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/Input/SubtitleParser.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/Output/SubtitleOutput.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/Output/VerboseConsole.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/BuiltInSubtitleFormats.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormat.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatAdobeEncoreDVD.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatAdvancedSubStationAlpha.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatAQTitle.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatDKSSubtitleFormat.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatKaraokeLyricsLRC.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatKaraokeLyricsVKT.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatMacSUB.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatMicroDVD.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatMPlayer.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatMPlayer2.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatMPSub.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatPanimator.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatPhoenixJapanimationSociety.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatPowerDivX.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatSofni.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatSubCreator1x.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatSubRip.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatSubStationAlpha.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatSubViewer1.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatSubViewer2.cs" subtype="Code" buildaction="Compile" />
+ <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatViPlaySubtitleFile.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
@@ -158,7 +250,6 @@
<ProjectReference type="Gac" localcopy="True" refto="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<ProjectReference type="Gac" localcopy="True" refto="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
- <ProjectReference type="Assembly" localcopy="True" specificVersion="False" refto="../sublib/build/sublib.dll" />
<ProjectReference type="Gac" localcopy="True" refto="gconf-sharp, Version=2.24.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
</References>
<LanguageParameters StartupObject="GnomeSubtitles.Execution.Executable" ApplicationIcon="." ctype="CSharpProjectParameters" />
diff --git a/src/External/NCharDet/Big5Statistics.cs b/src/External/NCharDet/Big5Statistics.cs
new file mode 100644
index 0000000..12758bc
--- /dev/null
+++ b/src/External/NCharDet/Big5Statistics.cs
@@ -0,0 +1,269 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+
+namespace org.mozilla.intl.chardet {
+
+////import java.lang.* ;
+
+public class Big5Statistics : nsEUCStatistics {
+
+ static float[] m_FirstByteFreq ;
+ static float m_FirstByteStdDev;
+ static float m_FirstByteMean;
+ static float m_FirstByteWeight;
+ static float[] m_SecondByteFreq;
+ static float m_SecondByteStdDev;
+ static float m_SecondByteMean;
+ static float m_SecondByteWeight;
+
+ public override float[] mFirstByteFreq() { return m_FirstByteFreq; }
+ public override float mFirstByteStdDev() { return m_FirstByteStdDev; }
+ public override float mFirstByteMean() { return m_FirstByteMean; }
+ public override float mFirstByteWeight() { return m_FirstByteWeight; }
+ public override float[] mSecondByteFreq() { return m_SecondByteFreq; }
+ public override float mSecondByteStdDev() { return m_SecondByteStdDev; }
+ public override float mSecondByteMean() { return m_SecondByteMean; }
+ public override float mSecondByteWeight() { return m_SecondByteWeight; }
+
+ public Big5Statistics() {
+
+ m_FirstByteFreq = new float[] {
+ 0.000000f, // FreqH[a1]
+ 0.000000f, // FreqH[a2]
+ 0.000000f, // FreqH[a3]
+ 0.114427f, // FreqH[a4]
+ 0.061058f, // FreqH[a5]
+ 0.075598f, // FreqH[a6]
+ 0.048386f, // FreqH[a7]
+ 0.063966f, // FreqH[a8]
+ 0.027094f, // FreqH[a9]
+ 0.095787f, // FreqH[aa]
+ 0.029525f, // FreqH[ab]
+ 0.031331f, // FreqH[ac]
+ 0.036915f, // FreqH[ad]
+ 0.021805f, // FreqH[ae]
+ 0.019349f, // FreqH[af]
+ 0.037496f, // FreqH[b0]
+ 0.018068f, // FreqH[b1]
+ 0.012760f, // FreqH[b2]
+ 0.030053f, // FreqH[b3]
+ 0.017339f, // FreqH[b4]
+ 0.016731f, // FreqH[b5]
+ 0.019501f, // FreqH[b6]
+ 0.011240f, // FreqH[b7]
+ 0.032973f, // FreqH[b8]
+ 0.016658f, // FreqH[b9]
+ 0.015872f, // FreqH[ba]
+ 0.021458f, // FreqH[bb]
+ 0.012378f, // FreqH[bc]
+ 0.017003f, // FreqH[bd]
+ 0.020802f, // FreqH[be]
+ 0.012454f, // FreqH[bf]
+ 0.009239f, // FreqH[c0]
+ 0.012829f, // FreqH[c1]
+ 0.007922f, // FreqH[c2]
+ 0.010079f, // FreqH[c3]
+ 0.009815f, // FreqH[c4]
+ 0.010104f, // FreqH[c5]
+ 0.000000f, // FreqH[c6]
+ 0.000000f, // FreqH[c7]
+ 0.000000f, // FreqH[c8]
+ 0.000053f, // FreqH[c9]
+ 0.000035f, // FreqH[ca]
+ 0.000105f, // FreqH[cb]
+ 0.000031f, // FreqH[cc]
+ 0.000088f, // FreqH[cd]
+ 0.000027f, // FreqH[ce]
+ 0.000027f, // FreqH[cf]
+ 0.000026f, // FreqH[d0]
+ 0.000035f, // FreqH[d1]
+ 0.000024f, // FreqH[d2]
+ 0.000034f, // FreqH[d3]
+ 0.000375f, // FreqH[d4]
+ 0.000025f, // FreqH[d5]
+ 0.000028f, // FreqH[d6]
+ 0.000020f, // FreqH[d7]
+ 0.000024f, // FreqH[d8]
+ 0.000028f, // FreqH[d9]
+ 0.000031f, // FreqH[da]
+ 0.000059f, // FreqH[db]
+ 0.000040f, // FreqH[dc]
+ 0.000030f, // FreqH[dd]
+ 0.000079f, // FreqH[de]
+ 0.000037f, // FreqH[df]
+ 0.000040f, // FreqH[e0]
+ 0.000023f, // FreqH[e1]
+ 0.000030f, // FreqH[e2]
+ 0.000027f, // FreqH[e3]
+ 0.000064f, // FreqH[e4]
+ 0.000020f, // FreqH[e5]
+ 0.000027f, // FreqH[e6]
+ 0.000025f, // FreqH[e7]
+ 0.000074f, // FreqH[e8]
+ 0.000019f, // FreqH[e9]
+ 0.000023f, // FreqH[ea]
+ 0.000021f, // FreqH[eb]
+ 0.000018f, // FreqH[ec]
+ 0.000017f, // FreqH[ed]
+ 0.000035f, // FreqH[ee]
+ 0.000021f, // FreqH[ef]
+ 0.000019f, // FreqH[f0]
+ 0.000025f, // FreqH[f1]
+ 0.000017f, // FreqH[f2]
+ 0.000037f, // FreqH[f3]
+ 0.000018f, // FreqH[f4]
+ 0.000018f, // FreqH[f5]
+ 0.000019f, // FreqH[f6]
+ 0.000022f, // FreqH[f7]
+ 0.000033f, // FreqH[f8]
+ 0.000032f, // FreqH[f9]
+ 0.000000f, // FreqH[fa]
+ 0.000000f, // FreqH[fb]
+ 0.000000f, // FreqH[fc]
+ 0.000000f, // FreqH[fd]
+ 0.000000f // FreqH[fe]
+ };
+
+ m_FirstByteStdDev = 0.020606f; // Lead Byte StdDev
+ m_FirstByteMean = 0.010638f; // Lead Byte Mean
+ m_FirstByteWeight = 0.675261f; // Lead Byte Weight
+
+ m_SecondByteFreq = new float[] {
+ 0.020256f, // FreqL[a1]
+ 0.003293f, // FreqL[a2]
+ 0.045811f, // FreqL[a3]
+ 0.016650f, // FreqL[a4]
+ 0.007066f, // FreqL[a5]
+ 0.004146f, // FreqL[a6]
+ 0.009229f, // FreqL[a7]
+ 0.007333f, // FreqL[a8]
+ 0.003296f, // FreqL[a9]
+ 0.005239f, // FreqL[aa]
+ 0.008282f, // FreqL[ab]
+ 0.003791f, // FreqL[ac]
+ 0.006116f, // FreqL[ad]
+ 0.003536f, // FreqL[ae]
+ 0.004024f, // FreqL[af]
+ 0.016654f, // FreqL[b0]
+ 0.009334f, // FreqL[b1]
+ 0.005429f, // FreqL[b2]
+ 0.033392f, // FreqL[b3]
+ 0.006121f, // FreqL[b4]
+ 0.008983f, // FreqL[b5]
+ 0.002801f, // FreqL[b6]
+ 0.004221f, // FreqL[b7]
+ 0.010357f, // FreqL[b8]
+ 0.014695f, // FreqL[b9]
+ 0.077937f, // FreqL[ba]
+ 0.006314f, // FreqL[bb]
+ 0.004020f, // FreqL[bc]
+ 0.007331f, // FreqL[bd]
+ 0.007150f, // FreqL[be]
+ 0.005341f, // FreqL[bf]
+ 0.009195f, // FreqL[c0]
+ 0.005350f, // FreqL[c1]
+ 0.005698f, // FreqL[c2]
+ 0.004472f, // FreqL[c3]
+ 0.007242f, // FreqL[c4]
+ 0.004039f, // FreqL[c5]
+ 0.011154f, // FreqL[c6]
+ 0.016184f, // FreqL[c7]
+ 0.004741f, // FreqL[c8]
+ 0.012814f, // FreqL[c9]
+ 0.007679f, // FreqL[ca]
+ 0.008045f, // FreqL[cb]
+ 0.016631f, // FreqL[cc]
+ 0.009451f, // FreqL[cd]
+ 0.016487f, // FreqL[ce]
+ 0.007287f, // FreqL[cf]
+ 0.012688f, // FreqL[d0]
+ 0.017421f, // FreqL[d1]
+ 0.013205f, // FreqL[d2]
+ 0.031480f, // FreqL[d3]
+ 0.003404f, // FreqL[d4]
+ 0.009149f, // FreqL[d5]
+ 0.008921f, // FreqL[d6]
+ 0.007514f, // FreqL[d7]
+ 0.008683f, // FreqL[d8]
+ 0.008203f, // FreqL[d9]
+ 0.031403f, // FreqL[da]
+ 0.011733f, // FreqL[db]
+ 0.015617f, // FreqL[dc]
+ 0.015306f, // FreqL[dd]
+ 0.004004f, // FreqL[de]
+ 0.010899f, // FreqL[df]
+ 0.009961f, // FreqL[e0]
+ 0.008388f, // FreqL[e1]
+ 0.010920f, // FreqL[e2]
+ 0.003925f, // FreqL[e3]
+ 0.008585f, // FreqL[e4]
+ 0.009108f, // FreqL[e5]
+ 0.015546f, // FreqL[e6]
+ 0.004659f, // FreqL[e7]
+ 0.006934f, // FreqL[e8]
+ 0.007023f, // FreqL[e9]
+ 0.020252f, // FreqL[ea]
+ 0.005387f, // FreqL[eb]
+ 0.024704f, // FreqL[ec]
+ 0.006963f, // FreqL[ed]
+ 0.002625f, // FreqL[ee]
+ 0.009512f, // FreqL[ef]
+ 0.002971f, // FreqL[f0]
+ 0.008233f, // FreqL[f1]
+ 0.010000f, // FreqL[f2]
+ 0.011973f, // FreqL[f3]
+ 0.010553f, // FreqL[f4]
+ 0.005945f, // FreqL[f5]
+ 0.006349f, // FreqL[f6]
+ 0.009401f, // FreqL[f7]
+ 0.008577f, // FreqL[f8]
+ 0.008186f, // FreqL[f9]
+ 0.008159f, // FreqL[fa]
+ 0.005033f, // FreqL[fb]
+ 0.008714f, // FreqL[fc]
+ 0.010614f, // FreqL[fd]
+ 0.006554f // FreqL[fe]
+ };
+
+ m_SecondByteStdDev = 0.009909f; // Trail Byte StdDev
+ m_SecondByteMean = 0.010638f; // Trail Byte Mean
+ m_SecondByteWeight = 0.324739f ; // Trial Byte Weight
+
+ }
+}
+
+} // namespace
diff --git a/src/External/NCharDet/COPYING-MPL b/src/External/NCharDet/COPYING-MPL
new file mode 100644
index 0000000..7a45bfe
--- /dev/null
+++ b/src/External/NCharDet/COPYING-MPL
@@ -0,0 +1,470 @@
+ MOZILLA PUBLIC LICENSE
+ Version 1.1
+
+ ---------------
+
+1. Definitions.
+
+ 1.0.1. "Commercial Use" means distribution or otherwise making the
+ Covered Code available to a third party.
+
+ 1.1. "Contributor" means each entity that creates or contributes to
+ the creation of Modifications.
+
+ 1.2. "Contributor Version" means the combination of the Original
+ Code, prior Modifications used by a Contributor, and the Modifications
+ made by that particular Contributor.
+
+ 1.3. "Covered Code" means the Original Code or Modifications or the
+ combination of the Original Code and Modifications, in each case
+ including portions thereof.
+
+ 1.4. "Electronic Distribution Mechanism" means a mechanism generally
+ accepted in the software development community for the electronic
+ transfer of data.
+
+ 1.5. "Executable" means Covered Code in any form other than Source
+ Code.
+
+ 1.6. "Initial Developer" means the individual or entity identified
+ as the Initial Developer in the Source Code notice required by Exhibit
+ A.
+
+ 1.7. "Larger Work" means a work which combines Covered Code or
+ portions thereof with code not governed by the terms of this License.
+
+ 1.8. "License" means this document.
+
+ 1.8.1. "Licensable" means having the right to grant, to the maximum
+ extent possible, whether at the time of the initial grant or
+ subsequently acquired, any and all of the rights conveyed herein.
+
+ 1.9. "Modifications" means any addition to or deletion from the
+ substance or structure of either the Original Code or any previous
+ Modifications. When Covered Code is released as a series of files, a
+ Modification is:
+ A. Any addition to or deletion from the contents of a file
+ containing Original Code or previous Modifications.
+
+ B. Any new file that contains any part of the Original Code or
+ previous Modifications.
+
+ 1.10. "Original Code" means Source Code of computer software code
+ which is described in the Source Code notice required by Exhibit A as
+ Original Code, and which, at the time of its release under this
+ License is not already Covered Code governed by this License.
+
+ 1.10.1. "Patent Claims" means any patent claim(s), now owned or
+ hereafter acquired, including without limitation, method, process,
+ and apparatus claims, in any patent Licensable by grantor.
+
+ 1.11. "Source Code" means the preferred form of the Covered Code for
+ making modifications to it, including all modules it contains, plus
+ any associated interface definition files, scripts used to control
+ compilation and installation of an Executable, or source code
+ differential comparisons against either the Original Code or another
+ well known, available Covered Code of the Contributor's choice. The
+ Source Code can be in a compressed or archival form, provided the
+ appropriate decompression or de-archiving software is widely available
+ for no charge.
+
+ 1.12. "You" (or "Your") means an individual or a legal entity
+ exercising rights under, and complying with all of the terms of, this
+ License or a future version of this License issued under Section 6.1.
+ For legal entities, "You" includes any entity which controls, is
+ controlled by, or is under common control with You. For purposes of
+ this definition, "control" means (a) the power, direct or indirect,
+ to cause the direction or management of such entity, whether by
+ contract or otherwise, or (b) ownership of more than fifty percent
+ (50%) of the outstanding shares or beneficial ownership of such
+ entity.
+
+2. Source Code License.
+
+ 2.1. The Initial Developer Grant.
+ The Initial Developer hereby grants You a world-wide, royalty-free,
+ non-exclusive license, subject to third party intellectual property
+ claims:
+ (a) under intellectual property rights (other than patent or
+ trademark) Licensable by Initial Developer to use, reproduce,
+ modify, display, perform, sublicense and distribute the Original
+ Code (or portions thereof) with or without Modifications, and/or
+ as part of a Larger Work; and
+
+ (b) under Patents Claims infringed by the making, using or
+ selling of Original Code, to make, have made, use, practice,
+ sell, and offer for sale, and/or otherwise dispose of the
+ Original Code (or portions thereof).
+
+ (c) the licenses granted in this Section 2.1(a) and (b) are
+ effective on the date Initial Developer first distributes
+ Original Code under the terms of this License.
+
+ (d) Notwithstanding Section 2.1(b) above, no patent license is
+ granted: 1) for code that You delete from the Original Code; 2)
+ separate from the Original Code; or 3) for infringements caused
+ by: i) the modification of the Original Code or ii) the
+ combination of the Original Code with other software or devices.
+
+ 2.2. Contributor Grant.
+ Subject to third party intellectual property claims, each Contributor
+ hereby grants You a world-wide, royalty-free, non-exclusive license
+
+ (a) under intellectual property rights (other than patent or
+ trademark) Licensable by Contributor, to use, reproduce, modify,
+ display, perform, sublicense and distribute the Modifications
+ created by such Contributor (or portions thereof) either on an
+ unmodified basis, with other Modifications, as Covered Code
+ and/or as part of a Larger Work; and
+
+ (b) under Patent Claims infringed by the making, using, or
+ selling of Modifications made by that Contributor either alone
+ and/or in combination with its Contributor Version (or portions
+ of such combination), to make, use, sell, offer for sale, have
+ made, and/or otherwise dispose of: 1) Modifications made by that
+ Contributor (or portions thereof); and 2) the combination of
+ Modifications made by that Contributor with its Contributor
+ Version (or portions of such combination).
+
+ (c) the licenses granted in Sections 2.2(a) and 2.2(b) are
+ effective on the date Contributor first makes Commercial Use of
+ the Covered Code.
+
+ (d) Notwithstanding Section 2.2(b) above, no patent license is
+ granted: 1) for any code that Contributor has deleted from the
+ Contributor Version; 2) separate from the Contributor Version;
+ 3) for infringements caused by: i) third party modifications of
+ Contributor Version or ii) the combination of Modifications made
+ by that Contributor with other software (except as part of the
+ Contributor Version) or other devices; or 4) under Patent Claims
+ infringed by Covered Code in the absence of Modifications made by
+ that Contributor.
+
+3. Distribution Obligations.
+
+ 3.1. Application of License.
+ The Modifications which You create or to which You contribute are
+ governed by the terms of this License, including without limitation
+ Section 2.2. The Source Code version of Covered Code may be
+ distributed only under the terms of this License or a future version
+ of this License released under Section 6.1, and You must include a
+ copy of this License with every copy of the Source Code You
+ distribute. You may not offer or impose any terms on any Source Code
+ version that alters or restricts the applicable version of this
+ License or the recipients' rights hereunder. However, You may include
+ an additional document offering the additional rights described in
+ Section 3.5.
+
+ 3.2. Availability of Source Code.
+ Any Modification which You create or to which You contribute must be
+ made available in Source Code form under the terms of this License
+ either on the same media as an Executable version or via an accepted
+ Electronic Distribution Mechanism to anyone to whom you made an
+ Executable version available; and if made available via Electronic
+ Distribution Mechanism, must remain available for at least twelve (12)
+ months after the date it initially became available, or at least six
+ (6) months after a subsequent version of that particular Modification
+ has been made available to such recipients. You are responsible for
+ ensuring that the Source Code version remains available even if the
+ Electronic Distribution Mechanism is maintained by a third party.
+
+ 3.3. Description of Modifications.
+ You must cause all Covered Code to which You contribute to contain a
+ file documenting the changes You made to create that Covered Code and
+ the date of any change. You must include a prominent statement that
+ the Modification is derived, directly or indirectly, from Original
+ Code provided by the Initial Developer and including the name of the
+ Initial Developer in (a) the Source Code, and (b) in any notice in an
+ Executable version or related documentation in which You describe the
+ origin or ownership of the Covered Code.
+
+ 3.4. Intellectual Property Matters
+ (a) Third Party Claims.
+ If Contributor has knowledge that a license under a third party's
+ intellectual property rights is required to exercise the rights
+ granted by such Contributor under Sections 2.1 or 2.2,
+ Contributor must include a text file with the Source Code
+ distribution titled "LEGAL" which describes the claim and the
+ party making the claim in sufficient detail that a recipient will
+ know whom to contact. If Contributor obtains such knowledge after
+ the Modification is made available as described in Section 3.2,
+ Contributor shall promptly modify the LEGAL file in all copies
+ Contributor makes available thereafter and shall take other steps
+ (such as notifying appropriate mailing lists or newsgroups)
+ reasonably calculated to inform those who received the Covered
+ Code that new knowledge has been obtained.
+
+ (b) Contributor APIs.
+ If Contributor's Modifications include an application programming
+ interface and Contributor has knowledge of patent licenses which
+ are reasonably necessary to implement that API, Contributor must
+ also include this information in the LEGAL file.
+
+ (c) Representations.
+ Contributor represents that, except as disclosed pursuant to
+ Section 3.4(a) above, Contributor believes that Contributor's
+ Modifications are Contributor's original creation(s) and/or
+ Contributor has sufficient rights to grant the rights conveyed by
+ this License.
+
+ 3.5. Required Notices.
+ You must duplicate the notice in Exhibit A in each file of the Source
+ Code. If it is not possible to put such notice in a particular Source
+ Code file due to its structure, then You must include such notice in a
+ location (such as a relevant directory) where a user would be likely
+ to look for such a notice. If You created one or more Modification(s)
+ You may add your name as a Contributor to the notice described in
+ Exhibit A. You must also duplicate this License in any documentation
+ for the Source Code where You describe recipients' rights or ownership
+ rights relating to Covered Code. You may choose to offer, and to
+ charge a fee for, warranty, support, indemnity or liability
+ obligations to one or more recipients of Covered Code. However, You
+ may do so only on Your own behalf, and not on behalf of the Initial
+ Developer or any Contributor. You must make it absolutely clear than
+ any such warranty, support, indemnity or liability obligation is
+ offered by You alone, and You hereby agree to indemnify the Initial
+ Developer and every Contributor for any liability incurred by the
+ Initial Developer or such Contributor as a result of warranty,
+ support, indemnity or liability terms You offer.
+
+ 3.6. Distribution of Executable Versions.
+ You may distribute Covered Code in Executable form only if the
+ requirements of Section 3.1-3.5 have been met for that Covered Code,
+ and if You include a notice stating that the Source Code version of
+ the Covered Code is available under the terms of this License,
+ including a description of how and where You have fulfilled the
+ obligations of Section 3.2. The notice must be conspicuously included
+ in any notice in an Executable version, related documentation or
+ collateral in which You describe recipients' rights relating to the
+ Covered Code. You may distribute the Executable version of Covered
+ Code or ownership rights under a license of Your choice, which may
+ contain terms different from this License, provided that You are in
+ compliance with the terms of this License and that the license for the
+ Executable version does not attempt to limit or alter the recipient's
+ rights in the Source Code version from the rights set forth in this
+ License. If You distribute the Executable version under a different
+ license You must make it absolutely clear that any terms which differ
+ from this License are offered by You alone, not by the Initial
+ Developer or any Contributor. You hereby agree to indemnify the
+ Initial Developer and every Contributor for any liability incurred by
+ the Initial Developer or such Contributor as a result of any such
+ terms You offer.
+
+ 3.7. Larger Works.
+ You may create a Larger Work by combining Covered Code with other code
+ not governed by the terms of this License and distribute the Larger
+ Work as a single product. In such a case, You must make sure the
+ requirements of this License are fulfilled for the Covered Code.
+
+4. Inability to Comply Due to Statute or Regulation.
+
+ If it is impossible for You to comply with any of the terms of this
+ License with respect to some or all of the Covered Code due to
+ statute, judicial order, or regulation then You must: (a) comply with
+ the terms of this License to the maximum extent possible; and (b)
+ describe the limitations and the code they affect. Such description
+ must be included in the LEGAL file described in Section 3.4 and must
+ be included with all distributions of the Source Code. Except to the
+ extent prohibited by statute or regulation, such description must be
+ sufficiently detailed for a recipient of ordinary skill to be able to
+ understand it.
+
+5. Application of this License.
+
+ This License applies to code to which the Initial Developer has
+ attached the notice in Exhibit A and to related Covered Code.
+
+6. Versions of the License.
+
+ 6.1. New Versions.
+ Netscape Communications Corporation ("Netscape") may publish revised
+ and/or new versions of the License from time to time. Each version
+ will be given a distinguishing version number.
+
+ 6.2. Effect of New Versions.
+ Once Covered Code has been published under a particular version of the
+ License, You may always continue to use it under the terms of that
+ version. You may also choose to use such Covered Code under the terms
+ of any subsequent version of the License published by Netscape. No one
+ other than Netscape has the right to modify the terms applicable to
+ Covered Code created under this License.
+
+ 6.3. Derivative Works.
+ If You create or use a modified version of this License (which you may
+ only do in order to apply it to code which is not already Covered Code
+ governed by this License), You must (a) rename Your license so that
+ the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
+ "MPL", "NPL" or any confusingly similar phrase do not appear in your
+ license (except to note that your license differs from this License)
+ and (b) otherwise make it clear that Your version of the license
+ contains terms which differ from the Mozilla Public License and
+ Netscape Public License. (Filling in the name of the Initial
+ Developer, Original Code or Contributor in the notice described in
+ Exhibit A shall not of themselves be deemed to be modifications of
+ this License.)
+
+7. DISCLAIMER OF WARRANTY.
+
+ COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
+ DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
+ THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
+ IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
+ YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
+ COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
+ OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
+ ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+
+8. TERMINATION.
+
+ 8.1. This License and the rights granted hereunder will terminate
+ automatically if You fail to comply with terms herein and fail to cure
+ such breach within 30 days of becoming aware of the breach. All
+ sublicenses to the Covered Code which are properly granted shall
+ survive any termination of this License. Provisions which, by their
+ nature, must remain in effect beyond the termination of this License
+ shall survive.
+
+ 8.2. If You initiate litigation by asserting a patent infringement
+ claim (excluding declatory judgment actions) against Initial Developer
+ or a Contributor (the Initial Developer or Contributor against whom
+ You file such action is referred to as "Participant") alleging that:
+
+ (a) such Participant's Contributor Version directly or indirectly
+ infringes any patent, then any and all rights granted by such
+ Participant to You under Sections 2.1 and/or 2.2 of this License
+ shall, upon 60 days notice from Participant terminate prospectively,
+ unless if within 60 days after receipt of notice You either: (i)
+ agree in writing to pay Participant a mutually agreeable reasonable
+ royalty for Your past and future use of Modifications made by such
+ Participant, or (ii) withdraw Your litigation claim with respect to
+ the Contributor Version against such Participant. If within 60 days
+ of notice, a reasonable royalty and payment arrangement are not
+ mutually agreed upon in writing by the parties or the litigation claim
+ is not withdrawn, the rights granted by Participant to You under
+ Sections 2.1 and/or 2.2 automatically terminate at the expiration of
+ the 60 day notice period specified above.
+
+ (b) any software, hardware, or device, other than such Participant's
+ Contributor Version, directly or indirectly infringes any patent, then
+ any rights granted to You by such Participant under Sections 2.1(b)
+ and 2.2(b) are revoked effective as of the date You first made, used,
+ sold, distributed, or had made, Modifications made by that
+ Participant.
+
+ 8.3. If You assert a patent infringement claim against Participant
+ alleging that such Participant's Contributor Version directly or
+ indirectly infringes any patent where such claim is resolved (such as
+ by license or settlement) prior to the initiation of patent
+ infringement litigation, then the reasonable value of the licenses
+ granted by such Participant under Sections 2.1 or 2.2 shall be taken
+ into account in determining the amount or value of any payment or
+ license.
+
+ 8.4. In the event of termination under Sections 8.1 or 8.2 above,
+ all end user license agreements (excluding distributors and resellers)
+ which have been validly granted by You or any distributor hereunder
+ prior to termination shall survive termination.
+
+9. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+ (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
+ DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
+ OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
+ ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
+ CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
+ WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
+ COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
+ INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
+ LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
+ RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
+ PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
+ EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
+ THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+10. U.S. GOVERNMENT END USERS.
+
+ The Covered Code is a "commercial item," as that term is defined in
+ 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
+ software" and "commercial computer software documentation," as such
+ terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
+ C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
+ all U.S. Government End Users acquire Covered Code with only those
+ rights set forth herein.
+
+11. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject
+ matter hereof. If any provision of this License is held to be
+ unenforceable, such provision shall be reformed only to the extent
+ necessary to make it enforceable. This License shall be governed by
+ California law provisions (except to the extent applicable law, if
+ any, provides otherwise), excluding its conflict-of-law provisions.
+ With respect to disputes in which at least one party is a citizen of,
+ or an entity chartered or registered to do business in the United
+ States of America, any litigation relating to this License shall be
+ subject to the jurisdiction of the Federal Courts of the Northern
+ District of California, with venue lying in Santa Clara County,
+ California, with the losing party responsible for costs, including
+ without limitation, court costs and reasonable attorneys' fees and
+ expenses. The application of the United Nations Convention on
+ Contracts for the International Sale of Goods is expressly excluded.
+ Any law or regulation which provides that the language of a contract
+ shall be construed against the drafter shall not apply to this
+ License.
+
+12. RESPONSIBILITY FOR CLAIMS.
+
+ As between Initial Developer and the Contributors, each party is
+ responsible for claims and damages arising, directly or indirectly,
+ out of its utilization of rights under this License and You agree to
+ work with Initial Developer and Contributors to distribute such
+ responsibility on an equitable basis. Nothing herein is intended or
+ shall be deemed to constitute any admission of liability.
+
+13. MULTIPLE-LICENSED CODE.
+
+ Initial Developer may designate portions of the Covered Code as
+ "Multiple-Licensed". "Multiple-Licensed" means that the Initial
+ Developer permits you to utilize portions of the Covered Code under
+ Your choice of the NPL or the alternative licenses, if any, specified
+ by the Initial Developer in the file described in Exhibit A.
+
+EXHIBIT A -Mozilla Public License.
+
+ ``The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in
+ compliance with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
+
+ Software distributed under the License is distributed on an "AS IS"
+ basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ License for the specific language governing rights and limitations
+ under the License.
+
+ The Original Code is ______________________________________.
+
+ The Initial Developer of the Original Code is ________________________.
+ Portions created by ______________________ are Copyright (C) ______
+ _______________________. All Rights Reserved.
+
+ Contributor(s): ______________________________________.
+
+ Alternatively, the contents of this file may be used under the terms
+ of the _____ license (the "[___] License"), in which case the
+ provisions of [______] License are applicable instead of those
+ above. If you wish to allow use of your version of this file only
+ under the terms of the [____] License and not to allow others to use
+ your version of this file under the MPL, indicate your decision by
+ deleting the provisions above and replace them with the notice and
+ other provisions required by the [___] License. If you do not delete
+ the provisions above, a recipient may use your version of this file
+ under either the MPL or the [___] License."
+
+ [NOTE: The text of this Exhibit A may differ slightly from the text of
+ the notices in the Source Code files of the Original Code. You should
+ use the text of this Exhibit A rather than the text found in the
+ Original Code Source Code for Your Modifications.]
+
diff --git a/src/External/NCharDet/EUCJPStatistics.cs b/src/External/NCharDet/EUCJPStatistics.cs
new file mode 100644
index 0000000..fd546b2
--- /dev/null
+++ b/src/External/NCharDet/EUCJPStatistics.cs
@@ -0,0 +1,272 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class EUCJPStatistics : nsEUCStatistics {
+
+
+ static float[] m_FirstByteFreq ;
+ static float m_FirstByteStdDev;
+ static float m_FirstByteMean;
+ static float m_FirstByteWeight;
+ static float[] m_SecondByteFreq;
+ static float m_SecondByteStdDev;
+ static float m_SecondByteMean;
+ static float m_SecondByteWeight;
+
+ public override float[] mFirstByteFreq() { return m_FirstByteFreq; }
+ public override float mFirstByteStdDev() { return m_FirstByteStdDev; }
+ public override float mFirstByteMean() { return m_FirstByteMean; }
+ public override float mFirstByteWeight() { return m_FirstByteWeight; }
+ public override float[] mSecondByteFreq() { return m_SecondByteFreq; }
+ public override float mSecondByteStdDev() { return m_SecondByteStdDev; }
+ public override float mSecondByteMean() { return m_SecondByteMean; }
+ public override float mSecondByteWeight() { return m_SecondByteWeight; }
+
+ public EUCJPStatistics() {
+
+ m_FirstByteFreq = new float[] {
+ 0.364808f, // FreqH[a1]
+ 0.000000f, // FreqH[a2]
+ 0.000000f, // FreqH[a3]
+ 0.145325f, // FreqH[a4]
+ 0.304891f, // FreqH[a5]
+ 0.000000f, // FreqH[a6]
+ 0.000000f, // FreqH[a7]
+ 0.000000f, // FreqH[a8]
+ 0.000000f, // FreqH[a9]
+ 0.000000f, // FreqH[aa]
+ 0.000000f, // FreqH[ab]
+ 0.000000f, // FreqH[ac]
+ 0.000000f, // FreqH[ad]
+ 0.000000f, // FreqH[ae]
+ 0.000000f, // FreqH[af]
+ 0.001835f, // FreqH[b0]
+ 0.010771f, // FreqH[b1]
+ 0.006462f, // FreqH[b2]
+ 0.001157f, // FreqH[b3]
+ 0.002114f, // FreqH[b4]
+ 0.003231f, // FreqH[b5]
+ 0.001356f, // FreqH[b6]
+ 0.007420f, // FreqH[b7]
+ 0.004189f, // FreqH[b8]
+ 0.003231f, // FreqH[b9]
+ 0.003032f, // FreqH[ba]
+ 0.033190f, // FreqH[bb]
+ 0.006303f, // FreqH[bc]
+ 0.006064f, // FreqH[bd]
+ 0.009973f, // FreqH[be]
+ 0.002354f, // FreqH[bf]
+ 0.003670f, // FreqH[c0]
+ 0.009135f, // FreqH[c1]
+ 0.001675f, // FreqH[c2]
+ 0.002792f, // FreqH[c3]
+ 0.002194f, // FreqH[c4]
+ 0.014720f, // FreqH[c5]
+ 0.011928f, // FreqH[c6]
+ 0.000878f, // FreqH[c7]
+ 0.013124f, // FreqH[c8]
+ 0.001077f, // FreqH[c9]
+ 0.009295f, // FreqH[ca]
+ 0.003471f, // FreqH[cb]
+ 0.002872f, // FreqH[cc]
+ 0.002433f, // FreqH[cd]
+ 0.000957f, // FreqH[ce]
+ 0.001636f, // FreqH[cf]
+ 0.000000f, // FreqH[d0]
+ 0.000000f, // FreqH[d1]
+ 0.000000f, // FreqH[d2]
+ 0.000000f, // FreqH[d3]
+ 0.000000f, // FreqH[d4]
+ 0.000000f, // FreqH[d5]
+ 0.000000f, // FreqH[d6]
+ 0.000000f, // FreqH[d7]
+ 0.000000f, // FreqH[d8]
+ 0.000000f, // FreqH[d9]
+ 0.000000f, // FreqH[da]
+ 0.000000f, // FreqH[db]
+ 0.000000f, // FreqH[dc]
+ 0.000000f, // FreqH[dd]
+ 0.000080f, // FreqH[de]
+ 0.000279f, // FreqH[df]
+ 0.000000f, // FreqH[e0]
+ 0.000000f, // FreqH[e1]
+ 0.000000f, // FreqH[e2]
+ 0.000000f, // FreqH[e3]
+ 0.000000f, // FreqH[e4]
+ 0.000000f, // FreqH[e5]
+ 0.000000f, // FreqH[e6]
+ 0.000000f, // FreqH[e7]
+ 0.000000f, // FreqH[e8]
+ 0.000000f, // FreqH[e9]
+ 0.000000f, // FreqH[ea]
+ 0.000000f, // FreqH[eb]
+ 0.000000f, // FreqH[ec]
+ 0.000000f, // FreqH[ed]
+ 0.000000f, // FreqH[ee]
+ 0.000000f, // FreqH[ef]
+ 0.000000f, // FreqH[f0]
+ 0.000000f, // FreqH[f1]
+ 0.000000f, // FreqH[f2]
+ 0.000000f, // FreqH[f3]
+ 0.000000f, // FreqH[f4]
+ 0.000000f, // FreqH[f5]
+ 0.000000f, // FreqH[f6]
+ 0.000000f, // FreqH[f7]
+ 0.000000f, // FreqH[f8]
+ 0.000000f, // FreqH[f9]
+ 0.000000f, // FreqH[fa]
+ 0.000000f, // FreqH[fb]
+ 0.000000f, // FreqH[fc]
+ 0.000080f, // FreqH[fd]
+ 0.000000f // FreqH[fe]
+
+ };
+
+ m_FirstByteStdDev = 0.050407f; // Lead Byte StdDev
+ m_FirstByteMean = 0.010638f; // Lead Byte Mean
+ m_FirstByteWeight = 0.640871f; // Lead Byte Weight
+
+ m_SecondByteFreq = new float[] {
+ 0.002473f, // FreqL[a1]
+ 0.039134f, // FreqL[a2]
+ 0.152745f, // FreqL[a3]
+ 0.009694f, // FreqL[a4]
+ 0.000359f, // FreqL[a5]
+ 0.022180f, // FreqL[a6]
+ 0.000758f, // FreqL[a7]
+ 0.004308f, // FreqL[a8]
+ 0.000160f, // FreqL[a9]
+ 0.002513f, // FreqL[aa]
+ 0.003072f, // FreqL[ab]
+ 0.001316f, // FreqL[ac]
+ 0.003830f, // FreqL[ad]
+ 0.001037f, // FreqL[ae]
+ 0.003590f, // FreqL[af]
+ 0.000957f, // FreqL[b0]
+ 0.000160f, // FreqL[b1]
+ 0.000239f, // FreqL[b2]
+ 0.006462f, // FreqL[b3]
+ 0.001596f, // FreqL[b4]
+ 0.031554f, // FreqL[b5]
+ 0.001316f, // FreqL[b6]
+ 0.002194f, // FreqL[b7]
+ 0.016555f, // FreqL[b8]
+ 0.003271f, // FreqL[b9]
+ 0.000678f, // FreqL[ba]
+ 0.000598f, // FreqL[bb]
+ 0.206438f, // FreqL[bc]
+ 0.000718f, // FreqL[bd]
+ 0.001077f, // FreqL[be]
+ 0.003710f, // FreqL[bf]
+ 0.001356f, // FreqL[c0]
+ 0.001356f, // FreqL[c1]
+ 0.000439f, // FreqL[c2]
+ 0.004388f, // FreqL[c3]
+ 0.005704f, // FreqL[c4]
+ 0.000878f, // FreqL[c5]
+ 0.010172f, // FreqL[c6]
+ 0.007061f, // FreqL[c7]
+ 0.014680f, // FreqL[c8]
+ 0.000638f, // FreqL[c9]
+ 0.025730f, // FreqL[ca]
+ 0.002792f, // FreqL[cb]
+ 0.000718f, // FreqL[cc]
+ 0.001795f, // FreqL[cd]
+ 0.091551f, // FreqL[ce]
+ 0.000758f, // FreqL[cf]
+ 0.003909f, // FreqL[d0]
+ 0.000558f, // FreqL[d1]
+ 0.031195f, // FreqL[d2]
+ 0.007061f, // FreqL[d3]
+ 0.001316f, // FreqL[d4]
+ 0.022579f, // FreqL[d5]
+ 0.006981f, // FreqL[d6]
+ 0.007260f, // FreqL[d7]
+ 0.001117f, // FreqL[d8]
+ 0.000239f, // FreqL[d9]
+ 0.012127f, // FreqL[da]
+ 0.000878f, // FreqL[db]
+ 0.003790f, // FreqL[dc]
+ 0.001077f, // FreqL[dd]
+ 0.000758f, // FreqL[de]
+ 0.002114f, // FreqL[df]
+ 0.002234f, // FreqL[e0]
+ 0.000678f, // FreqL[e1]
+ 0.002992f, // FreqL[e2]
+ 0.003311f, // FreqL[e3]
+ 0.023416f, // FreqL[e4]
+ 0.001237f, // FreqL[e5]
+ 0.002753f, // FreqL[e6]
+ 0.005146f, // FreqL[e7]
+ 0.002194f, // FreqL[e8]
+ 0.007021f, // FreqL[e9]
+ 0.008497f, // FreqL[ea]
+ 0.013763f, // FreqL[eb]
+ 0.011768f, // FreqL[ec]
+ 0.006303f, // FreqL[ed]
+ 0.001915f, // FreqL[ee]
+ 0.000638f, // FreqL[ef]
+ 0.008776f, // FreqL[f0]
+ 0.000918f, // FreqL[f1]
+ 0.003431f, // FreqL[f2]
+ 0.057603f, // FreqL[f3]
+ 0.000439f, // FreqL[f4]
+ 0.000439f, // FreqL[f5]
+ 0.000758f, // FreqL[f6]
+ 0.002872f, // FreqL[f7]
+ 0.001675f, // FreqL[f8]
+ 0.011050f, // FreqL[f9]
+ 0.000000f, // FreqL[fa]
+ 0.000279f, // FreqL[fb]
+ 0.012127f, // FreqL[fc]
+ 0.000718f, // FreqL[fd]
+ 0.007380f // FreqL[fe]
+
+ };
+
+ m_SecondByteStdDev = 0.028247f; // Trail Byte StdDev
+ m_SecondByteMean = 0.010638f; // Trail Byte Mean
+ m_SecondByteWeight = 0.359129f; // Trial Byte Weight
+ }
+
+}
+
+} // namespace
diff --git a/src/External/NCharDet/EUCKRStatistics.cs b/src/External/NCharDet/EUCKRStatistics.cs
new file mode 100644
index 0000000..1845b7a
--- /dev/null
+++ b/src/External/NCharDet/EUCKRStatistics.cs
@@ -0,0 +1,272 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class EUCKRStatistics : nsEUCStatistics {
+
+
+ static float[] m_FirstByteFreq ;
+ static float m_FirstByteStdDev;
+ static float m_FirstByteMean;
+ static float m_FirstByteWeight;
+ static float[] m_SecondByteFreq;
+ static float m_SecondByteStdDev;
+ static float m_SecondByteMean;
+ static float m_SecondByteWeight;
+
+ public override float[] mFirstByteFreq() { return m_FirstByteFreq; }
+ public override float mFirstByteStdDev() { return m_FirstByteStdDev; }
+ public override float mFirstByteMean() { return m_FirstByteMean; }
+ public override float mFirstByteWeight() { return m_FirstByteWeight; }
+ public override float[] mSecondByteFreq() { return m_SecondByteFreq; }
+ public override float mSecondByteStdDev() { return m_SecondByteStdDev; }
+ public override float mSecondByteMean() { return m_SecondByteMean; }
+ public override float mSecondByteWeight() { return m_SecondByteWeight; }
+
+ public EUCKRStatistics() {
+
+ m_FirstByteFreq = new float[] {
+ 0.000000f, // FreqH[a1]
+ 0.000000f, // FreqH[a2]
+ 0.000000f, // FreqH[a3]
+ 0.000000f, // FreqH[a4]
+ 0.000000f, // FreqH[a5]
+ 0.000000f, // FreqH[a6]
+ 0.000000f, // FreqH[a7]
+ 0.000412f, // FreqH[a8]
+ 0.000000f, // FreqH[a9]
+ 0.000000f, // FreqH[aa]
+ 0.000000f, // FreqH[ab]
+ 0.000000f, // FreqH[ac]
+ 0.000000f, // FreqH[ad]
+ 0.000000f, // FreqH[ae]
+ 0.000000f, // FreqH[af]
+ 0.057502f, // FreqH[b0]
+ 0.033182f, // FreqH[b1]
+ 0.002267f, // FreqH[b2]
+ 0.016076f, // FreqH[b3]
+ 0.014633f, // FreqH[b4]
+ 0.032976f, // FreqH[b5]
+ 0.004122f, // FreqH[b6]
+ 0.011336f, // FreqH[b7]
+ 0.058533f, // FreqH[b8]
+ 0.024526f, // FreqH[b9]
+ 0.025969f, // FreqH[ba]
+ 0.054411f, // FreqH[bb]
+ 0.019580f, // FreqH[bc]
+ 0.063273f, // FreqH[bd]
+ 0.113974f, // FreqH[be]
+ 0.029885f, // FreqH[bf]
+ 0.150041f, // FreqH[c0]
+ 0.059151f, // FreqH[c1]
+ 0.002679f, // FreqH[c2]
+ 0.009893f, // FreqH[c3]
+ 0.014839f, // FreqH[c4]
+ 0.026381f, // FreqH[c5]
+ 0.015045f, // FreqH[c6]
+ 0.069456f, // FreqH[c7]
+ 0.089860f, // FreqH[c8]
+ 0.000000f, // FreqH[c9]
+ 0.000000f, // FreqH[ca]
+ 0.000000f, // FreqH[cb]
+ 0.000000f, // FreqH[cc]
+ 0.000000f, // FreqH[cd]
+ 0.000000f, // FreqH[ce]
+ 0.000000f, // FreqH[cf]
+ 0.000000f, // FreqH[d0]
+ 0.000000f, // FreqH[d1]
+ 0.000000f, // FreqH[d2]
+ 0.000000f, // FreqH[d3]
+ 0.000000f, // FreqH[d4]
+ 0.000000f, // FreqH[d5]
+ 0.000000f, // FreqH[d6]
+ 0.000000f, // FreqH[d7]
+ 0.000000f, // FreqH[d8]
+ 0.000000f, // FreqH[d9]
+ 0.000000f, // FreqH[da]
+ 0.000000f, // FreqH[db]
+ 0.000000f, // FreqH[dc]
+ 0.000000f, // FreqH[dd]
+ 0.000000f, // FreqH[de]
+ 0.000000f, // FreqH[df]
+ 0.000000f, // FreqH[e0]
+ 0.000000f, // FreqH[e1]
+ 0.000000f, // FreqH[e2]
+ 0.000000f, // FreqH[e3]
+ 0.000000f, // FreqH[e4]
+ 0.000000f, // FreqH[e5]
+ 0.000000f, // FreqH[e6]
+ 0.000000f, // FreqH[e7]
+ 0.000000f, // FreqH[e8]
+ 0.000000f, // FreqH[e9]
+ 0.000000f, // FreqH[ea]
+ 0.000000f, // FreqH[eb]
+ 0.000000f, // FreqH[ec]
+ 0.000000f, // FreqH[ed]
+ 0.000000f, // FreqH[ee]
+ 0.000000f, // FreqH[ef]
+ 0.000000f, // FreqH[f0]
+ 0.000000f, // FreqH[f1]
+ 0.000000f, // FreqH[f2]
+ 0.000000f, // FreqH[f3]
+ 0.000000f, // FreqH[f4]
+ 0.000000f, // FreqH[f5]
+ 0.000000f, // FreqH[f6]
+ 0.000000f, // FreqH[f7]
+ 0.000000f, // FreqH[f8]
+ 0.000000f, // FreqH[f9]
+ 0.000000f, // FreqH[fa]
+ 0.000000f, // FreqH[fb]
+ 0.000000f, // FreqH[fc]
+ 0.000000f, // FreqH[fd]
+ 0.000000f // FreqH[fe]
+
+ };
+
+ m_FirstByteStdDev = 0.025593f; // Lead Byte StdDev
+ m_FirstByteMean = 0.010638f; // Lead Byte Mean
+ m_FirstByteWeight = 0.647437f; // Lead Byte Weight
+
+ m_SecondByteFreq = new float[] {
+ 0.016694f, // FreqL[a1]
+ 0.000000f, // FreqL[a2]
+ 0.012778f, // FreqL[a3]
+ 0.030091f, // FreqL[a4]
+ 0.002679f, // FreqL[a5]
+ 0.006595f, // FreqL[a6]
+ 0.001855f, // FreqL[a7]
+ 0.000824f, // FreqL[a8]
+ 0.005977f, // FreqL[a9]
+ 0.004740f, // FreqL[aa]
+ 0.003092f, // FreqL[ab]
+ 0.000824f, // FreqL[ac]
+ 0.019580f, // FreqL[ad]
+ 0.037304f, // FreqL[ae]
+ 0.008244f, // FreqL[af]
+ 0.014633f, // FreqL[b0]
+ 0.001031f, // FreqL[b1]
+ 0.000000f, // FreqL[b2]
+ 0.003298f, // FreqL[b3]
+ 0.002061f, // FreqL[b4]
+ 0.006183f, // FreqL[b5]
+ 0.005977f, // FreqL[b6]
+ 0.000824f, // FreqL[b7]
+ 0.021847f, // FreqL[b8]
+ 0.014839f, // FreqL[b9]
+ 0.052968f, // FreqL[ba]
+ 0.017312f, // FreqL[bb]
+ 0.007626f, // FreqL[bc]
+ 0.000412f, // FreqL[bd]
+ 0.000824f, // FreqL[be]
+ 0.011129f, // FreqL[bf]
+ 0.000000f, // FreqL[c0]
+ 0.000412f, // FreqL[c1]
+ 0.001649f, // FreqL[c2]
+ 0.005977f, // FreqL[c3]
+ 0.065746f, // FreqL[c4]
+ 0.020198f, // FreqL[c5]
+ 0.021434f, // FreqL[c6]
+ 0.014633f, // FreqL[c7]
+ 0.004122f, // FreqL[c8]
+ 0.001649f, // FreqL[c9]
+ 0.000824f, // FreqL[ca]
+ 0.000824f, // FreqL[cb]
+ 0.051937f, // FreqL[cc]
+ 0.019580f, // FreqL[cd]
+ 0.023289f, // FreqL[ce]
+ 0.026381f, // FreqL[cf]
+ 0.040396f, // FreqL[d0]
+ 0.009068f, // FreqL[d1]
+ 0.001443f, // FreqL[d2]
+ 0.003710f, // FreqL[d3]
+ 0.007420f, // FreqL[d4]
+ 0.001443f, // FreqL[d5]
+ 0.013190f, // FreqL[d6]
+ 0.002885f, // FreqL[d7]
+ 0.000412f, // FreqL[d8]
+ 0.003298f, // FreqL[d9]
+ 0.025969f, // FreqL[da]
+ 0.000412f, // FreqL[db]
+ 0.000412f, // FreqL[dc]
+ 0.006183f, // FreqL[dd]
+ 0.003298f, // FreqL[de]
+ 0.066983f, // FreqL[df]
+ 0.002679f, // FreqL[e0]
+ 0.002267f, // FreqL[e1]
+ 0.011129f, // FreqL[e2]
+ 0.000412f, // FreqL[e3]
+ 0.010099f, // FreqL[e4]
+ 0.015251f, // FreqL[e5]
+ 0.007626f, // FreqL[e6]
+ 0.043899f, // FreqL[e7]
+ 0.003710f, // FreqL[e8]
+ 0.002679f, // FreqL[e9]
+ 0.001443f, // FreqL[ea]
+ 0.010923f, // FreqL[eb]
+ 0.002885f, // FreqL[ec]
+ 0.009068f, // FreqL[ed]
+ 0.019992f, // FreqL[ee]
+ 0.000412f, // FreqL[ef]
+ 0.008450f, // FreqL[f0]
+ 0.005153f, // FreqL[f1]
+ 0.000000f, // FreqL[f2]
+ 0.010099f, // FreqL[f3]
+ 0.000000f, // FreqL[f4]
+ 0.001649f, // FreqL[f5]
+ 0.012160f, // FreqL[f6]
+ 0.011542f, // FreqL[f7]
+ 0.006595f, // FreqL[f8]
+ 0.001855f, // FreqL[f9]
+ 0.010923f, // FreqL[fa]
+ 0.000412f, // FreqL[fb]
+ 0.023702f, // FreqL[fc]
+ 0.003710f, // FreqL[fd]
+ 0.001855f // FreqL[fe]
+
+ };
+
+ m_SecondByteStdDev = 0.013937f; // Trail Byte StdDev
+ m_SecondByteMean = 0.010638f; // Trail Byte Mean
+ m_SecondByteWeight = 0.352563f; // Trial Byte Weight
+ }
+
+}
+
+} // namespace
diff --git a/src/External/NCharDet/EUCTWStatistics.cs b/src/External/NCharDet/EUCTWStatistics.cs
new file mode 100644
index 0000000..8beefe1
--- /dev/null
+++ b/src/External/NCharDet/EUCTWStatistics.cs
@@ -0,0 +1,270 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class EUCTWStatistics : nsEUCStatistics {
+
+
+ static float[] m_FirstByteFreq ;
+ static float m_FirstByteStdDev;
+ static float m_FirstByteMean;
+ static float m_FirstByteWeight;
+ static float[] m_SecondByteFreq;
+ static float m_SecondByteStdDev;
+ static float m_SecondByteMean;
+ static float m_SecondByteWeight;
+
+ public override float[] mFirstByteFreq() { return m_FirstByteFreq; }
+ public override float mFirstByteStdDev() { return m_FirstByteStdDev; }
+ public override float mFirstByteMean() { return m_FirstByteMean; }
+ public override float mFirstByteWeight() { return m_FirstByteWeight; }
+ public override float[] mSecondByteFreq() { return m_SecondByteFreq; }
+ public override float mSecondByteStdDev() { return m_SecondByteStdDev; }
+ public override float mSecondByteMean() { return m_SecondByteMean; }
+ public override float mSecondByteWeight() { return m_SecondByteWeight; }
+
+ public EUCTWStatistics() {
+
+ m_FirstByteFreq = new float[] {
+ 0.000000f, // FreqH[a1]
+ 0.000000f, // FreqH[a2]
+ 0.000000f, // FreqH[a3]
+ 0.000000f, // FreqH[a4]
+ 0.000000f, // FreqH[a5]
+ 0.000000f, // FreqH[a6]
+ 0.000000f, // FreqH[a7]
+ 0.000000f, // FreqH[a8]
+ 0.000000f, // FreqH[a9]
+ 0.000000f, // FreqH[aa]
+ 0.000000f, // FreqH[ab]
+ 0.000000f, // FreqH[ac]
+ 0.000000f, // FreqH[ad]
+ 0.000000f, // FreqH[ae]
+ 0.000000f, // FreqH[af]
+ 0.000000f, // FreqH[b0]
+ 0.000000f, // FreqH[b1]
+ 0.000000f, // FreqH[b2]
+ 0.000000f, // FreqH[b3]
+ 0.000000f, // FreqH[b4]
+ 0.000000f, // FreqH[b5]
+ 0.000000f, // FreqH[b6]
+ 0.000000f, // FreqH[b7]
+ 0.000000f, // FreqH[b8]
+ 0.000000f, // FreqH[b9]
+ 0.000000f, // FreqH[ba]
+ 0.000000f, // FreqH[bb]
+ 0.000000f, // FreqH[bc]
+ 0.000000f, // FreqH[bd]
+ 0.000000f, // FreqH[be]
+ 0.000000f, // FreqH[bf]
+ 0.000000f, // FreqH[c0]
+ 0.000000f, // FreqH[c1]
+ 0.000000f, // FreqH[c2]
+ 0.000000f, // FreqH[c3]
+ 0.119286f, // FreqH[c4]
+ 0.052233f, // FreqH[c5]
+ 0.044126f, // FreqH[c6]
+ 0.052494f, // FreqH[c7]
+ 0.045906f, // FreqH[c8]
+ 0.019038f, // FreqH[c9]
+ 0.032465f, // FreqH[ca]
+ 0.026252f, // FreqH[cb]
+ 0.025502f, // FreqH[cc]
+ 0.015963f, // FreqH[cd]
+ 0.052493f, // FreqH[ce]
+ 0.019256f, // FreqH[cf]
+ 0.015137f, // FreqH[d0]
+ 0.031782f, // FreqH[d1]
+ 0.017370f, // FreqH[d2]
+ 0.018494f, // FreqH[d3]
+ 0.015575f, // FreqH[d4]
+ 0.016621f, // FreqH[d5]
+ 0.007444f, // FreqH[d6]
+ 0.011642f, // FreqH[d7]
+ 0.013916f, // FreqH[d8]
+ 0.019159f, // FreqH[d9]
+ 0.016445f, // FreqH[da]
+ 0.007851f, // FreqH[db]
+ 0.011079f, // FreqH[dc]
+ 0.022842f, // FreqH[dd]
+ 0.015513f, // FreqH[de]
+ 0.010033f, // FreqH[df]
+ 0.009950f, // FreqH[e0]
+ 0.010347f, // FreqH[e1]
+ 0.013103f, // FreqH[e2]
+ 0.015371f, // FreqH[e3]
+ 0.012502f, // FreqH[e4]
+ 0.007436f, // FreqH[e5]
+ 0.018253f, // FreqH[e6]
+ 0.014134f, // FreqH[e7]
+ 0.008907f, // FreqH[e8]
+ 0.005411f, // FreqH[e9]
+ 0.009570f, // FreqH[ea]
+ 0.013598f, // FreqH[eb]
+ 0.006092f, // FreqH[ec]
+ 0.007409f, // FreqH[ed]
+ 0.008432f, // FreqH[ee]
+ 0.005816f, // FreqH[ef]
+ 0.009349f, // FreqH[f0]
+ 0.005472f, // FreqH[f1]
+ 0.007170f, // FreqH[f2]
+ 0.007420f, // FreqH[f3]
+ 0.003681f, // FreqH[f4]
+ 0.007523f, // FreqH[f5]
+ 0.004610f, // FreqH[f6]
+ 0.006154f, // FreqH[f7]
+ 0.003348f, // FreqH[f8]
+ 0.005074f, // FreqH[f9]
+ 0.005922f, // FreqH[fa]
+ 0.005254f, // FreqH[fb]
+ 0.004682f, // FreqH[fc]
+ 0.002093f, // FreqH[fd]
+ 0.000000f // FreqH[fe]
+ };
+
+ m_FirstByteStdDev = 0.016681f; // Lead Byte StdDev
+ m_FirstByteMean = 0.010638f; // Lead Byte Mean
+ m_FirstByteWeight = 0.715599f; // Lead Byte Weight
+
+ m_SecondByteFreq = new float[] {
+ 0.028933f, // FreqL[a1]
+ 0.011371f, // FreqL[a2]
+ 0.011053f, // FreqL[a3]
+ 0.007232f, // FreqL[a4]
+ 0.010192f, // FreqL[a5]
+ 0.004093f, // FreqL[a6]
+ 0.015043f, // FreqL[a7]
+ 0.011752f, // FreqL[a8]
+ 0.022387f, // FreqL[a9]
+ 0.008410f, // FreqL[aa]
+ 0.012448f, // FreqL[ab]
+ 0.007473f, // FreqL[ac]
+ 0.003594f, // FreqL[ad]
+ 0.007139f, // FreqL[ae]
+ 0.018912f, // FreqL[af]
+ 0.006083f, // FreqL[b0]
+ 0.003302f, // FreqL[b1]
+ 0.010215f, // FreqL[b2]
+ 0.008791f, // FreqL[b3]
+ 0.024236f, // FreqL[b4]
+ 0.014107f, // FreqL[b5]
+ 0.014108f, // FreqL[b6]
+ 0.010303f, // FreqL[b7]
+ 0.009728f, // FreqL[b8]
+ 0.007877f, // FreqL[b9]
+ 0.009719f, // FreqL[ba]
+ 0.007952f, // FreqL[bb]
+ 0.021028f, // FreqL[bc]
+ 0.005764f, // FreqL[bd]
+ 0.009341f, // FreqL[be]
+ 0.006591f, // FreqL[bf]
+ 0.012517f, // FreqL[c0]
+ 0.005921f, // FreqL[c1]
+ 0.008982f, // FreqL[c2]
+ 0.008771f, // FreqL[c3]
+ 0.012802f, // FreqL[c4]
+ 0.005926f, // FreqL[c5]
+ 0.008342f, // FreqL[c6]
+ 0.003086f, // FreqL[c7]
+ 0.006843f, // FreqL[c8]
+ 0.007576f, // FreqL[c9]
+ 0.004734f, // FreqL[ca]
+ 0.016404f, // FreqL[cb]
+ 0.008803f, // FreqL[cc]
+ 0.008071f, // FreqL[cd]
+ 0.005349f, // FreqL[ce]
+ 0.008566f, // FreqL[cf]
+ 0.010840f, // FreqL[d0]
+ 0.015401f, // FreqL[d1]
+ 0.031904f, // FreqL[d2]
+ 0.008670f, // FreqL[d3]
+ 0.011479f, // FreqL[d4]
+ 0.010936f, // FreqL[d5]
+ 0.007617f, // FreqL[d6]
+ 0.008995f, // FreqL[d7]
+ 0.008114f, // FreqL[d8]
+ 0.008658f, // FreqL[d9]
+ 0.005934f, // FreqL[da]
+ 0.010452f, // FreqL[db]
+ 0.009142f, // FreqL[dc]
+ 0.004519f, // FreqL[dd]
+ 0.008339f, // FreqL[de]
+ 0.007476f, // FreqL[df]
+ 0.007027f, // FreqL[e0]
+ 0.006025f, // FreqL[e1]
+ 0.021804f, // FreqL[e2]
+ 0.024248f, // FreqL[e3]
+ 0.015895f, // FreqL[e4]
+ 0.003768f, // FreqL[e5]
+ 0.010171f, // FreqL[e6]
+ 0.010007f, // FreqL[e7]
+ 0.010178f, // FreqL[e8]
+ 0.008316f, // FreqL[e9]
+ 0.006832f, // FreqL[ea]
+ 0.006364f, // FreqL[eb]
+ 0.009141f, // FreqL[ec]
+ 0.009148f, // FreqL[ed]
+ 0.012081f, // FreqL[ee]
+ 0.011914f, // FreqL[ef]
+ 0.004464f, // FreqL[f0]
+ 0.014257f, // FreqL[f1]
+ 0.006907f, // FreqL[f2]
+ 0.011292f, // FreqL[f3]
+ 0.018622f, // FreqL[f4]
+ 0.008149f, // FreqL[f5]
+ 0.004636f, // FreqL[f6]
+ 0.006612f, // FreqL[f7]
+ 0.013478f, // FreqL[f8]
+ 0.012614f, // FreqL[f9]
+ 0.005186f, // FreqL[fa]
+ 0.048285f, // FreqL[fb]
+ 0.006816f, // FreqL[fc]
+ 0.006743f, // FreqL[fd]
+ 0.008671f // FreqL[fe]
+ };
+
+ m_SecondByteStdDev = 0.006630f; // Trail Byte StdDev
+ m_SecondByteMean = 0.010638f; // Trail Byte Mean
+ m_SecondByteWeight = 0.284401f; // Trial Byte Weight
+ }
+
+}
+
+} // namespace
diff --git a/src/External/NCharDet/GB2312Statistics.cs b/src/External/NCharDet/GB2312Statistics.cs
new file mode 100644
index 0000000..9ff504f
--- /dev/null
+++ b/src/External/NCharDet/GB2312Statistics.cs
@@ -0,0 +1,273 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class GB2312Statistics : nsEUCStatistics {
+
+
+ static float[] m_FirstByteFreq ;
+ static float m_FirstByteStdDev;
+ static float m_FirstByteMean;
+ static float m_FirstByteWeight;
+ static float[] m_SecondByteFreq;
+ static float m_SecondByteStdDev;
+ static float m_SecondByteMean;
+ static float m_SecondByteWeight;
+
+ public override float[] mFirstByteFreq() { return m_FirstByteFreq; }
+ public override float mFirstByteStdDev() { return m_FirstByteStdDev; }
+ public override float mFirstByteMean() { return m_FirstByteMean; }
+ public override float mFirstByteWeight() { return m_FirstByteWeight; }
+ public override float[] mSecondByteFreq() { return m_SecondByteFreq; }
+ public override float mSecondByteStdDev() { return m_SecondByteStdDev; }
+ public override float mSecondByteMean() { return m_SecondByteMean; }
+ public override float mSecondByteWeight() { return m_SecondByteWeight; }
+
+ public GB2312Statistics() {
+
+ m_FirstByteFreq = new float[] {
+ 0.011628f, // FreqH[a1]
+ 0.000000f, // FreqH[a2]
+ 0.000000f, // FreqH[a3]
+ 0.000000f, // FreqH[a4]
+ 0.000000f, // FreqH[a5]
+ 0.000000f, // FreqH[a6]
+ 0.000000f, // FreqH[a7]
+ 0.000000f, // FreqH[a8]
+ 0.000000f, // FreqH[a9]
+ 0.000000f, // FreqH[aa]
+ 0.000000f, // FreqH[ab]
+ 0.000000f, // FreqH[ac]
+ 0.000000f, // FreqH[ad]
+ 0.000000f, // FreqH[ae]
+ 0.000000f, // FreqH[af]
+ 0.011628f, // FreqH[b0]
+ 0.012403f, // FreqH[b1]
+ 0.009302f, // FreqH[b2]
+ 0.003876f, // FreqH[b3]
+ 0.017829f, // FreqH[b4]
+ 0.037209f, // FreqH[b5]
+ 0.008527f, // FreqH[b6]
+ 0.010078f, // FreqH[b7]
+ 0.019380f, // FreqH[b8]
+ 0.054264f, // FreqH[b9]
+ 0.010078f, // FreqH[ba]
+ 0.041085f, // FreqH[bb]
+ 0.020930f, // FreqH[bc]
+ 0.018605f, // FreqH[bd]
+ 0.010078f, // FreqH[be]
+ 0.013178f, // FreqH[bf]
+ 0.016279f, // FreqH[c0]
+ 0.006202f, // FreqH[c1]
+ 0.009302f, // FreqH[c2]
+ 0.017054f, // FreqH[c3]
+ 0.011628f, // FreqH[c4]
+ 0.008527f, // FreqH[c5]
+ 0.004651f, // FreqH[c6]
+ 0.006202f, // FreqH[c7]
+ 0.017829f, // FreqH[c8]
+ 0.024806f, // FreqH[c9]
+ 0.020155f, // FreqH[ca]
+ 0.013953f, // FreqH[cb]
+ 0.032558f, // FreqH[cc]
+ 0.035659f, // FreqH[cd]
+ 0.068217f, // FreqH[ce]
+ 0.010853f, // FreqH[cf]
+ 0.036434f, // FreqH[d0]
+ 0.117054f, // FreqH[d1]
+ 0.027907f, // FreqH[d2]
+ 0.100775f, // FreqH[d3]
+ 0.010078f, // FreqH[d4]
+ 0.017829f, // FreqH[d5]
+ 0.062016f, // FreqH[d6]
+ 0.012403f, // FreqH[d7]
+ 0.000000f, // FreqH[d8]
+ 0.000000f, // FreqH[d9]
+ 0.000000f, // FreqH[da]
+ 0.000000f, // FreqH[db]
+ 0.000000f, // FreqH[dc]
+ 0.000000f, // FreqH[dd]
+ 0.000000f, // FreqH[de]
+ 0.000000f, // FreqH[df]
+ 0.000000f, // FreqH[e0]
+ 0.000000f, // FreqH[e1]
+ 0.000000f, // FreqH[e2]
+ 0.000000f, // FreqH[e3]
+ 0.000000f, // FreqH[e4]
+ 0.000000f, // FreqH[e5]
+ 0.000000f, // FreqH[e6]
+ 0.000000f, // FreqH[e7]
+ 0.000000f, // FreqH[e8]
+ 0.000000f, // FreqH[e9]
+ 0.001550f, // FreqH[ea]
+ 0.000000f, // FreqH[eb]
+ 0.000000f, // FreqH[ec]
+ 0.000000f, // FreqH[ed]
+ 0.000000f, // FreqH[ee]
+ 0.000000f, // FreqH[ef]
+ 0.000000f, // FreqH[f0]
+ 0.000000f, // FreqH[f1]
+ 0.000000f, // FreqH[f2]
+ 0.000000f, // FreqH[f3]
+ 0.000000f, // FreqH[f4]
+ 0.000000f, // FreqH[f5]
+ 0.000000f, // FreqH[f6]
+ 0.000000f, // FreqH[f7]
+ 0.000000f, // FreqH[f8]
+ 0.000000f, // FreqH[f9]
+ 0.000000f, // FreqH[fa]
+ 0.000000f, // FreqH[fb]
+ 0.000000f, // FreqH[fc]
+ 0.000000f, // FreqH[fd]
+ 0.000000f // FreqH[fe]
+
+ };
+
+ m_FirstByteStdDev = 0.020081f; // Lead Byte StdDev
+ m_FirstByteMean = 0.010638f; // Lead Byte Mean
+ m_FirstByteWeight = 0.586533f; // Lead Byte Weight
+
+ m_SecondByteFreq = new float[] {
+ 0.006202f, // FreqL[a1]
+ 0.031008f, // FreqL[a2]
+ 0.005426f, // FreqL[a3]
+ 0.003101f, // FreqL[a4]
+ 0.001550f, // FreqL[a5]
+ 0.003101f, // FreqL[a6]
+ 0.082171f, // FreqL[a7]
+ 0.014729f, // FreqL[a8]
+ 0.006977f, // FreqL[a9]
+ 0.001550f, // FreqL[aa]
+ 0.013953f, // FreqL[ab]
+ 0.000000f, // FreqL[ac]
+ 0.013953f, // FreqL[ad]
+ 0.010078f, // FreqL[ae]
+ 0.008527f, // FreqL[af]
+ 0.006977f, // FreqL[b0]
+ 0.004651f, // FreqL[b1]
+ 0.003101f, // FreqL[b2]
+ 0.003101f, // FreqL[b3]
+ 0.003101f, // FreqL[b4]
+ 0.008527f, // FreqL[b5]
+ 0.003101f, // FreqL[b6]
+ 0.005426f, // FreqL[b7]
+ 0.005426f, // FreqL[b8]
+ 0.005426f, // FreqL[b9]
+ 0.003101f, // FreqL[ba]
+ 0.001550f, // FreqL[bb]
+ 0.006202f, // FreqL[bc]
+ 0.014729f, // FreqL[bd]
+ 0.010853f, // FreqL[be]
+ 0.000000f, // FreqL[bf]
+ 0.011628f, // FreqL[c0]
+ 0.000000f, // FreqL[c1]
+ 0.031783f, // FreqL[c2]
+ 0.013953f, // FreqL[c3]
+ 0.030233f, // FreqL[c4]
+ 0.039535f, // FreqL[c5]
+ 0.008527f, // FreqL[c6]
+ 0.015504f, // FreqL[c7]
+ 0.000000f, // FreqL[c8]
+ 0.003101f, // FreqL[c9]
+ 0.008527f, // FreqL[ca]
+ 0.016279f, // FreqL[cb]
+ 0.005426f, // FreqL[cc]
+ 0.001550f, // FreqL[cd]
+ 0.013953f, // FreqL[ce]
+ 0.013953f, // FreqL[cf]
+ 0.044961f, // FreqL[d0]
+ 0.003101f, // FreqL[d1]
+ 0.004651f, // FreqL[d2]
+ 0.006977f, // FreqL[d3]
+ 0.001550f, // FreqL[d4]
+ 0.005426f, // FreqL[d5]
+ 0.012403f, // FreqL[d6]
+ 0.001550f, // FreqL[d7]
+ 0.015504f, // FreqL[d8]
+ 0.000000f, // FreqL[d9]
+ 0.006202f, // FreqL[da]
+ 0.001550f, // FreqL[db]
+ 0.000000f, // FreqL[dc]
+ 0.007752f, // FreqL[dd]
+ 0.006977f, // FreqL[de]
+ 0.001550f, // FreqL[df]
+ 0.009302f, // FreqL[e0]
+ 0.011628f, // FreqL[e1]
+ 0.004651f, // FreqL[e2]
+ 0.010853f, // FreqL[e3]
+ 0.012403f, // FreqL[e4]
+ 0.017829f, // FreqL[e5]
+ 0.005426f, // FreqL[e6]
+ 0.024806f, // FreqL[e7]
+ 0.000000f, // FreqL[e8]
+ 0.006202f, // FreqL[e9]
+ 0.000000f, // FreqL[ea]
+ 0.082171f, // FreqL[eb]
+ 0.015504f, // FreqL[ec]
+ 0.004651f, // FreqL[ed]
+ 0.000000f, // FreqL[ee]
+ 0.006977f, // FreqL[ef]
+ 0.004651f, // FreqL[f0]
+ 0.000000f, // FreqL[f1]
+ 0.008527f, // FreqL[f2]
+ 0.012403f, // FreqL[f3]
+ 0.004651f, // FreqL[f4]
+ 0.003876f, // FreqL[f5]
+ 0.003101f, // FreqL[f6]
+ 0.022481f, // FreqL[f7]
+ 0.024031f, // FreqL[f8]
+ 0.001550f, // FreqL[f9]
+ 0.047287f, // FreqL[fa]
+ 0.009302f, // FreqL[fb]
+ 0.001550f, // FreqL[fc]
+ 0.005426f, // FreqL[fd]
+ 0.017054f // FreqL[fe]
+
+ };
+
+ m_SecondByteStdDev = 0.014156f; // Trail Byte StdDev
+ m_SecondByteMean = 0.010638f; // Trail Byte Mean
+ m_SecondByteWeight = 0.413467f; // Trial Byte Weight
+ }
+
+}
+
+
+} // namespace
diff --git a/src/External/NCharDet/nsBIG5Verifier.cs b/src/External/NCharDet/nsBIG5Verifier.cs
new file mode 100644
index 0000000..dafbe19
--- /dev/null
+++ b/src/External/NCharDet/nsBIG5Verifier.cs
@@ -0,0 +1,116 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+/*
+ * DO NOT EDIT THIS DOCUMENT MANUALLY !!!
+ * THIS FILE IS AUTOMATICALLY GENERATED BY THE TOOLS UNDER
+ * AutoDetect/tools/
+ */
+using System;
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class nsBIG5Verifier : nsVerifier {
+
+ static int[] m_cclass ;
+ static int[] m_states ;
+ static int m_stFactor ;
+ static String m_charset ;
+
+ public override int[] cclass() { return m_cclass ; }
+ public override int[] states() { return m_states ; }
+ public override int stFactor() { return m_stFactor ; }
+ public override String charset() { return m_charset ; }
+
+ public nsBIG5Verifier() {
+
+ m_cclass = new int[256/8] ;
+
+ m_cclass[0] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[1] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[2] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[3] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[4] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[5] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[6] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[7] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[8] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[9] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[10] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[11] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[12] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[13] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[14] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[15] = ((int)((( ((int)((( ((int)((( 1) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[16] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[17] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[18] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[19] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[20] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (4))) )))))) ;
+ m_cclass[21] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[22] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[23] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[24] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[25] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[26] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[27] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[28] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[29] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[30] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[31] = ((int)((( ((int)((( ((int)((( 0) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+
+
+
+ m_states = new int[3] ;
+
+ m_states[0] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)((( 3) << 4) | (eStart))) ) << 8) | ( ((int)(((eStart) << 4) | (eError))) )))))) ;
+ m_states[1] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eItsMe))) ) << 8) | (((int)(((eItsMe) << 4) | ( eItsMe))) ))) ) << 16) | ( ((int)((( ((int)(((eItsMe) << 4) | (eItsMe))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[2] = ((int)((( ((int)((( ((int)((( eStart) << 4) | (eStart))) ) << 8) | (((int)(((eStart) << 4) | ( eStart))) ))) ) << 16) | ( ((int)((( ((int)(((eStart) << 4) | (eStart))) ) << 8) | ( ((int)(((eStart) << 4) | (eError))) )))))) ;
+
+
+
+ m_charset = "Big5";
+ m_stFactor = 5;
+
+ }
+
+ public override bool isUCS2() { return false; }
+
+
+}
+
+} // namespace
diff --git a/src/External/NCharDet/nsCP1252Verifier.cs b/src/External/NCharDet/nsCP1252Verifier.cs
new file mode 100644
index 0000000..7bdf72f
--- /dev/null
+++ b/src/External/NCharDet/nsCP1252Verifier.cs
@@ -0,0 +1,116 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+/*
+ * DO NOT EDIT THIS DOCUMENT MANUALLY !!!
+ * THIS FILE IS AUTOMATICALLY GENERATED BY THE TOOLS UNDER
+ * AutoDetect/tools/
+ */
+using System;
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class nsCP1252Verifier : nsVerifier {
+
+ static int[] m_cclass ;
+ static int[] m_states ;
+ static int m_stFactor ;
+ static String m_charset ;
+
+ public override int[] cclass() { return m_cclass ; }
+ public override int[] states() { return m_states ; }
+ public override int stFactor() { return m_stFactor ; }
+ public override String charset() { return m_charset ; }
+
+ public nsCP1252Verifier() {
+
+ m_cclass = new int[256/8] ;
+
+ m_cclass[0] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (1))) )))))) ;
+ m_cclass[1] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[2] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[3] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[4] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[5] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[6] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[7] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[8] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[9] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[10] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[11] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[12] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[13] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[14] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[15] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[16] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((0) << 4) | (2))) )))))) ;
+ m_cclass[17] = ((int)((( ((int)((( ((int)((( 0) << 4) | (1))) ) << 8) | (((int)(((0) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (1))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[18] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (0))) )))))) ;
+ m_cclass[19] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((0) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (1))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[20] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[21] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[22] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[23] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[24] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[25] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[26] = ((int)((( ((int)((( ((int)((( 2) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[27] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[28] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[29] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[30] = ((int)((( ((int)((( ((int)((( 2) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[31] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+
+
+
+ m_states = new int[3] ;
+
+ m_states[0] = ((int)((( ((int)((( ((int)((( eItsMe) << 4) | (eItsMe))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eStart))) ) << 8) | ( ((int)((( 3) << 4) | (eError))) )))))) ;
+ m_states[1] = ((int)((( ((int)((( ((int)((( eError) << 4) | ( 4))) ) << 8) | (((int)((( 5) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eStart) << 4) | ( 4))) ) << 8) | ( ((int)(((eError) << 4) | (eItsMe))) )))))) ;
+ m_states[2] = ((int)((( ((int)((( ((int)((( eStart) << 4) | (eStart))) ) << 8) | (((int)(((eStart) << 4) | ( eStart))) ))) ) << 16) | ( ((int)((( ((int)(((eStart) << 4) | (eStart))) ) << 8) | ( ((int)((( 4) << 4) | (eError))) )))))) ;
+
+
+
+ m_charset = "windows-1252";
+ m_stFactor = 3;
+
+ }
+
+ public override bool isUCS2() { return false; }
+
+
+}
+
+} // namespace
diff --git a/src/External/NCharDet/nsDetector.cs b/src/External/NCharDet/nsDetector.cs
new file mode 100644
index 0000000..eb97c2c
--- /dev/null
+++ b/src/External/NCharDet/nsDetector.cs
@@ -0,0 +1,93 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+using System;
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class nsDetector : nsPSMDetector
+ , nsICharsetDetector {
+
+ nsICharsetDetectionObserver mObserver = null ;
+
+ public nsDetector() : base(){
+ //super() ;
+ }
+
+ public nsDetector(int langFlag) : base(langFlag) {
+ //super(langFlag) ;
+ }
+
+ public void Init(nsICharsetDetectionObserver aObserver) {
+
+ mObserver = aObserver ;
+ return ;
+
+ }
+
+ public bool DoIt(byte[] aBuf, int aLen, bool oDontFeedMe) {
+
+ if (aBuf == null || oDontFeedMe )
+ return false ;
+
+ this.HandleData(aBuf, aLen) ;
+ return mDone ;
+ }
+
+ public void Done() {
+ this.DataEnd() ;
+ return ;
+ }
+
+ public override void Report(String charset) {
+ if (mObserver != null)
+ mObserver.Notify(charset) ;
+ }
+
+ public bool isAscii(byte[] aBuf, int aLen) {
+
+ for(int i=0; i<aLen; i++) {
+ if ((0x0080 & aBuf[i]) != 0) {
+ return false ;
+ }
+ }
+ return true ;
+ }
+}
+
+
+} // namespace
diff --git a/src/External/NCharDet/nsEUCJPVerifier.cs b/src/External/NCharDet/nsEUCJPVerifier.cs
new file mode 100644
index 0000000..320d18b
--- /dev/null
+++ b/src/External/NCharDet/nsEUCJPVerifier.cs
@@ -0,0 +1,118 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+/*
+ * DO NOT EDIT THIS DOCUMENT MANUALLY !!!
+ * THIS FILE IS AUTOMATICALLY GENERATED BY THE TOOLS UNDER
+ * AutoDetect/tools/
+ */
+using System;
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class nsEUCJPVerifier : nsVerifier {
+
+ static int[] m_cclass ;
+ static int[] m_states ;
+ static int m_stFactor ;
+ static String m_charset ;
+
+ public override int[] cclass() { return m_cclass ; }
+ public override int[] states() { return m_states ; }
+ public override int stFactor() { return m_stFactor ; }
+ public override String charset() { return m_charset ; }
+
+ public nsEUCJPVerifier() {
+
+ m_cclass = new int[256/8] ;
+
+ m_cclass[0] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[1] = ((int)((( ((int)((( ((int)((( 5) << 4) | (5))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[2] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[3] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((5) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[4] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[5] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[6] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[7] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[8] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[9] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[10] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[11] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[12] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[13] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[14] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[15] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[16] = ((int)((( ((int)((( ((int)((( 5) << 4) | (5))) ) << 8) | (((int)(((5) << 4) | ( 5))) ))) ) << 16) | ( ((int)((( ((int)(((5) << 4) | (5))) ) << 8) | ( ((int)(((5) << 4) | (5))) )))))) ;
+ m_cclass[17] = ((int)((( ((int)((( ((int)((( 3) << 4) | (1))) ) << 8) | (((int)(((5) << 4) | ( 5))) ))) ) << 16) | ( ((int)((( ((int)(((5) << 4) | (5))) ) << 8) | ( ((int)(((5) << 4) | (5))) )))))) ;
+ m_cclass[18] = ((int)((( ((int)((( ((int)((( 5) << 4) | (5))) ) << 8) | (((int)(((5) << 4) | ( 5))) ))) ) << 16) | ( ((int)((( ((int)(((5) << 4) | (5))) ) << 8) | ( ((int)(((5) << 4) | (5))) )))))) ;
+ m_cclass[19] = ((int)((( ((int)((( ((int)((( 5) << 4) | (5))) ) << 8) | (((int)(((5) << 4) | ( 5))) ))) ) << 16) | ( ((int)((( ((int)(((5) << 4) | (5))) ) << 8) | ( ((int)(((5) << 4) | (5))) )))))) ;
+ m_cclass[20] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (5))) )))))) ;
+ m_cclass[21] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[22] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[23] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[24] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[25] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[26] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[27] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[28] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[29] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[30] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[31] = ((int)((( ((int)((( ((int)((( 5) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+
+
+
+ m_states = new int[5] ;
+
+ m_states[0] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eStart))) ))) ) << 16) | ( ((int)((( ((int)((( 5) << 4) | ( 3))) ) << 8) | ( ((int)((( 4) << 4) | ( 3))) )))))) ;
+ m_states[1] = ((int)((( ((int)((( ((int)((( eItsMe) << 4) | (eItsMe))) ) << 8) | (((int)(((eItsMe) << 4) | ( eItsMe))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[2] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eStart))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eStart))) ) << 8) | ( ((int)(((eItsMe) << 4) | (eItsMe))) )))))) ;
+ m_states[3] = ((int)((( ((int)((( ((int)((( eError) << 4) | ( 3))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eStart))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[4] = ((int)((( ((int)((( ((int)((( eStart) << 4) | (eStart))) ) << 8) | (((int)(((eStart) << 4) | ( eStart))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | ( 3))) )))))) ;
+
+
+
+ m_charset = "EUC-JP";
+ m_stFactor = 6;
+
+ }
+
+ public override bool isUCS2() { return false; }
+
+
+}
+
+} // namespace
diff --git a/src/External/NCharDet/nsEUCKRVerifier.cs b/src/External/NCharDet/nsEUCKRVerifier.cs
new file mode 100644
index 0000000..65a4f4e
--- /dev/null
+++ b/src/External/NCharDet/nsEUCKRVerifier.cs
@@ -0,0 +1,116 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+/*
+ * DO NOT EDIT THIS DOCUMENT MANUALLY !!!
+ * THIS FILE IS AUTOMATICALLY GENERATED BY THE TOOLS UNDER
+ * AutoDetect/tools/
+ */
+using System;
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class nsEUCKRVerifier : nsVerifier {
+
+ static int[] m_cclass ;
+ static int[] m_states ;
+ static int m_stFactor ;
+ static String m_charset ;
+
+ public override int[] cclass() { return m_cclass ; }
+ public override int[] states() { return m_states ; }
+ public override int stFactor() { return m_stFactor ; }
+ public override String charset() { return m_charset ; }
+
+ public nsEUCKRVerifier() {
+
+ m_cclass = new int[256/8] ;
+
+ m_cclass[0] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[1] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[2] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[3] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[4] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[5] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[6] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[7] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[8] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[9] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[10] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[11] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[12] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[13] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[14] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[15] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[16] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[17] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[18] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[19] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[20] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (0))) )))))) ;
+ m_cclass[21] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[22] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[23] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[24] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[25] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((3) << 4) | (2))) )))))) ;
+ m_cclass[26] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[27] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[28] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[29] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[30] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[31] = ((int)((( ((int)((( ((int)((( 0) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+
+
+
+ m_states = new int[2] ;
+
+ m_states[0] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | ( 3))) ) << 8) | ( ((int)(((eStart) << 4) | (eError))) )))))) ;
+ m_states[1] = ((int)((( ((int)((( ((int)((( eStart) << 4) | (eStart))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eItsMe) << 4) | (eItsMe))) ) << 8) | ( ((int)(((eItsMe) << 4) | (eItsMe))) )))))) ;
+
+
+
+ m_charset = "EUC-KR";
+ m_stFactor = 4;
+
+ }
+
+ public override bool isUCS2() { return false; }
+
+
+}
+
+
+} // namespace
diff --git a/src/External/NCharDet/nsEUCSampler.cs b/src/External/NCharDet/nsEUCSampler.cs
new file mode 100644
index 0000000..a8d113c
--- /dev/null
+++ b/src/External/NCharDet/nsEUCSampler.cs
@@ -0,0 +1,147 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+using System;
+namespace org.mozilla.intl.chardet {
+//import java.lang.* ;
+
+public class nsEUCSampler {
+
+ int mTotal = 0;
+ int mThreshold = 200 ;
+ int mState = 0;
+
+ public int[] mFirstByteCnt = new int[94] ;
+ public int[] mSecondByteCnt = new int[94] ;
+ public float[] mFirstByteFreq = new float[94] ;
+ public float[] mSecondByteFreq = new float[94];
+
+ public nsEUCSampler() {
+ Reset() ;
+ }
+
+ public void Reset() {
+ mTotal = 0 ;
+ mState = 0 ;
+ for(int i=0; i<94; i++)
+ mFirstByteCnt[i] = mSecondByteCnt[i] = 0 ;
+ }
+
+ public bool EnoughData() { return mTotal > mThreshold; }
+
+ public bool GetSomeData() { return mTotal > 1; }
+
+ public bool Sample(byte[] aIn, int aLen) {
+
+ if(mState == 1)
+ return false;
+
+ int p = 0;
+
+ // if(aLen + mTotal > 0x80000000)
+ // aLen = 0x80000000 - mTotal;
+
+ int i;
+ for(i=0; (i<aLen) && (1 != mState) ;i++,p++)
+ {
+ switch(mState) {
+ case 0:
+ if( ( aIn[p] & 0x0080 ) != 0 )
+ {
+ if((0xff==(0xff&aIn[p])) || ( 0xa1>(0xff&aIn[p]))) {
+ mState = 1;
+ } else {
+ mTotal++;
+ mFirstByteCnt[(0xff&aIn[p]) - 0xa1]++;
+ mState = 2;
+ }
+ }
+ break;
+ case 1:
+ break;
+ case 2:
+ if( (aIn[p] & 0x0080) != 0 )
+ {
+ if((0xff == (0xff&aIn[p]))
+ || ( 0xa1 > (0xff&aIn[p]))) {
+ mState = 1;
+ } else {
+ mTotal++;
+ mSecondByteCnt[(0xff&aIn[p]) - 0xa1]++;
+ mState = 0;
+ }
+ } else {
+ mState = 1;
+ }
+ break;
+ default:
+ mState = 1;
+ break;
+ }
+ }
+ return (1 != mState );
+ }
+
+
+ public void CalFreq() {
+ for(int i = 0 ; i < 94; i++) {
+ mFirstByteFreq[i] = (float)mFirstByteCnt[i] / (float)mTotal;
+ mSecondByteFreq[i] = (float)mSecondByteCnt[i] / (float)mTotal;
+ }
+ }
+
+ public float GetScore(float[] aFirstByteFreq, float aFirstByteWeight,
+ float[] aSecondByteFreq, float aSecondByteWeight)
+ {
+ return aFirstByteWeight * GetScore(aFirstByteFreq, mFirstByteFreq) +
+ aSecondByteWeight * GetScore(aSecondByteFreq, mSecondByteFreq);
+ }
+
+ public float GetScore(float[] array1, float[] array2) {
+ float s;
+ float sum=0.0f;
+
+ for(int i=0;i<94;i++) {
+ s = array1[i] - array2[i];
+ sum += s * s;
+ }
+ return (float)Math.Sqrt((double)sum) / 94.0f;
+ }
+}
+
+
+
+} // namespace
diff --git a/src/External/NCharDet/nsEUCStatistics.cs b/src/External/NCharDet/nsEUCStatistics.cs
new file mode 100644
index 0000000..7a6753e
--- /dev/null
+++ b/src/External/NCharDet/nsEUCStatistics.cs
@@ -0,0 +1,59 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public abstract class nsEUCStatistics {
+
+ public abstract float[] mFirstByteFreq() ;
+ public abstract float mFirstByteStdDev();
+ public abstract float mFirstByteMean();
+ public abstract float mFirstByteWeight();
+ public abstract float[] mSecondByteFreq();
+ public abstract float mSecondByteStdDev();
+ public abstract float mSecondByteMean();
+ public abstract float mSecondByteWeight();
+
+ public nsEUCStatistics() {
+ }
+
+}
+
+
+} // namespace
diff --git a/src/External/NCharDet/nsEUCTWVerifier.cs b/src/External/NCharDet/nsEUCTWVerifier.cs
new file mode 100644
index 0000000..6c2b71d
--- /dev/null
+++ b/src/External/NCharDet/nsEUCTWVerifier.cs
@@ -0,0 +1,119 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+/*
+ * DO NOT EDIT THIS DOCUMENT MANUALLY !!!
+ * THIS FILE IS AUTOMATICALLY GENERATED BY THE TOOLS UNDER
+ * AutoDetect/tools/
+ */
+using System;
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class nsEUCTWVerifier : nsVerifier {
+
+ static int[] m_cclass ;
+ static int[] m_states ;
+ static int m_stFactor ;
+ static String m_charset ;
+
+ public override int[] cclass() { return m_cclass ; }
+ public override int[] states() { return m_states ; }
+ public override int stFactor() { return m_stFactor ; }
+ public override String charset() { return m_charset ; }
+
+ public nsEUCTWVerifier() {
+
+ m_cclass = new int[256/8] ;
+
+ m_cclass[0] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[1] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[2] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[3] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[4] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[5] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[6] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[7] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[8] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[9] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[10] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[11] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[12] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[13] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[14] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[15] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[16] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[17] = ((int)((( ((int)((( ((int)((( 0) << 4) | (6))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[18] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[19] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[20] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((3) << 4) | (0))) )))))) ;
+ m_cclass[21] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((5) << 4) | (5))) )))))) ;
+ m_cclass[22] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[23] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[24] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (3))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[25] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[26] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[27] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[28] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[29] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[30] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[31] = ((int)((( ((int)((( ((int)((( 0) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+
+
+
+ m_states = new int[6] ;
+
+ m_states[0] = ((int)((( ((int)((( ((int)((( eError) << 4) | ( 4))) ) << 8) | (((int)((( 3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)((( 3) << 4) | (eStart))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[1] = ((int)((( ((int)((( ((int)((( eItsMe) << 4) | (eItsMe))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[2] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eStart))) ) << 8) | (((int)(((eError) << 4) | ( eItsMe))) ))) ) << 16) | ( ((int)((( ((int)(((eItsMe) << 4) | (eItsMe))) ) << 8) | ( ((int)(((eItsMe) << 4) | (eItsMe))) )))))) ;
+ m_states[3] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eStart))) ) << 8) | ( ((int)(((eStart) << 4) | (eStart))) )))))) ;
+ m_states[4] = ((int)((( ((int)((( ((int)((( eStart) << 4) | (eStart))) ) << 8) | (((int)(((eError) << 4) | ( eStart))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | ( 5))) )))))) ;
+ m_states[5] = ((int)((( ((int)((( ((int)((( eStart) << 4) | (eStart))) ) << 8) | (((int)(((eStart) << 4) | ( eStart))) ))) ) << 16) | ( ((int)((( ((int)(((eStart) << 4) | (eStart))) ) << 8) | ( ((int)(((eError) << 4) | (eStart))) )))))) ;
+
+
+
+ m_charset = "x-euc-tw";
+ m_stFactor = 7;
+
+ }
+
+ public override bool isUCS2() { return false; }
+
+
+}
+
+} // namespace
diff --git a/src/External/NCharDet/nsGB18030Verifier.cs b/src/External/NCharDet/nsGB18030Verifier.cs
new file mode 100644
index 0000000..32251d6
--- /dev/null
+++ b/src/External/NCharDet/nsGB18030Verifier.cs
@@ -0,0 +1,119 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+/*
+ * DO NOT EDIT THIS DOCUMENT MANUALLY !!!
+ * THIS FILE IS AUTOMATICALLY GENERATED BY THE TOOLS UNDER
+ * AutoDetect/tools/
+ */
+using System;
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class nsGB18030Verifier : nsVerifier {
+
+ static int[] m_cclass ;
+ static int[] m_states ;
+ static int m_stFactor ;
+ static String m_charset ;
+
+ public override int[] cclass() { return m_cclass ; }
+ public override int[] states() { return m_states ; }
+ public override int stFactor() { return m_stFactor ; }
+ public override String charset() { return m_charset ; }
+
+ public nsGB18030Verifier() {
+
+ m_cclass = new int[256/8] ;
+
+ m_cclass[0] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[1] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[2] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[3] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[4] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[5] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[6] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[7] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[8] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[9] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[10] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[11] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[12] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[13] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[14] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[15] = ((int)((( ((int)((( ((int)((( 4) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[16] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (5))) )))))) ;
+ m_cclass[17] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (6))) )))))) ;
+ m_cclass[18] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (6))) )))))) ;
+ m_cclass[19] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (6))) )))))) ;
+ m_cclass[20] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (6))) )))))) ;
+ m_cclass[21] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (6))) )))))) ;
+ m_cclass[22] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (6))) )))))) ;
+ m_cclass[23] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (6))) )))))) ;
+ m_cclass[24] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (6))) )))))) ;
+ m_cclass[25] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (6))) )))))) ;
+ m_cclass[26] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (6))) )))))) ;
+ m_cclass[27] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (6))) )))))) ;
+ m_cclass[28] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (6))) )))))) ;
+ m_cclass[29] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (6))) )))))) ;
+ m_cclass[30] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (6))) )))))) ;
+ m_cclass[31] = ((int)((( ((int)((( ((int)((( 0) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (6))) )))))) ;
+
+
+
+ m_states = new int[6] ;
+
+ m_states[0] = ((int)((( ((int)((( ((int)((( eError) << 4) | ( 3))) ) << 8) | (((int)(((eStart) << 4) | ( eStart))) ))) ) << 16) | ( ((int)((( ((int)(((eStart) << 4) | (eStart))) ) << 8) | ( ((int)(((eStart) << 4) | (eError))) )))))) ;
+ m_states[1] = ((int)((( ((int)((( ((int)((( eItsMe) << 4) | (eItsMe))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[2] = ((int)((( ((int)((( ((int)((( eStart) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eItsMe))) ))) ) << 16) | ( ((int)((( ((int)(((eItsMe) << 4) | (eItsMe))) ) << 8) | ( ((int)(((eItsMe) << 4) | (eItsMe))) )))))) ;
+ m_states[3] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eStart) << 4) | (eStart))) ) << 8) | ( ((int)(((eError) << 4) | ( 4))) )))))) ;
+ m_states[4] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eItsMe))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | ( 5))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[5] = ((int)((( ((int)((( ((int)((( eStart) << 4) | (eStart))) ) << 8) | (((int)(((eStart) << 4) | ( eStart))) ))) ) << 16) | ( ((int)((( ((int)(((eStart) << 4) | (eStart))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+
+
+
+ m_charset = "GB18030";
+ m_stFactor = 7;
+
+ }
+
+ public override bool isUCS2() { return false; }
+
+
+}
+
+} // namespace
diff --git a/src/External/NCharDet/nsGB2312Verifier.cs b/src/External/NCharDet/nsGB2312Verifier.cs
new file mode 100644
index 0000000..14239ae
--- /dev/null
+++ b/src/External/NCharDet/nsGB2312Verifier.cs
@@ -0,0 +1,116 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+/*
+ * DO NOT EDIT THIS DOCUMENT MANUALLY !!!
+ * THIS FILE IS AUTOMATICALLY GENERATED BY THE TOOLS UNDER
+ * AutoDetect/tools/
+ */
+using System;
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class nsGB2312Verifier : nsVerifier {
+
+ static int[] m_cclass ;
+ static int[] m_states ;
+ static int m_stFactor ;
+ static String m_charset ;
+
+ public override int[] cclass() { return m_cclass ; }
+ public override int[] states() { return m_states ; }
+ public override int stFactor() { return m_stFactor ; }
+ public override String charset() { return m_charset ; }
+
+ public nsGB2312Verifier() {
+
+ m_cclass = new int[256/8] ;
+
+ m_cclass[0] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[1] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[2] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[3] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[4] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[5] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[6] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[7] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[8] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[9] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[10] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[11] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[12] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[13] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[14] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[15] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[16] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[17] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[18] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[19] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[20] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (0))) )))))) ;
+ m_cclass[21] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[22] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[23] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[24] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[25] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[26] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[27] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[28] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[29] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[30] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[31] = ((int)((( ((int)((( ((int)((( 0) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+
+
+
+ m_states = new int[2] ;
+
+ m_states[0] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | ( 3))) ) << 8) | ( ((int)(((eStart) << 4) | (eError))) )))))) ;
+ m_states[1] = ((int)((( ((int)((( ((int)((( eStart) << 4) | (eStart))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eItsMe) << 4) | (eItsMe))) ) << 8) | ( ((int)(((eItsMe) << 4) | (eItsMe))) )))))) ;
+
+
+
+ m_charset = "GB2312";
+ m_stFactor = 4;
+
+ }
+
+ public override bool isUCS2() { return false; }
+
+
+}
+
+
+} // namespace
diff --git a/src/External/NCharDet/nsHZVerifier.cs b/src/External/NCharDet/nsHZVerifier.cs
new file mode 100644
index 0000000..d9331bf
--- /dev/null
+++ b/src/External/NCharDet/nsHZVerifier.cs
@@ -0,0 +1,120 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+/*
+ * DO NOT EDIT THIS DOCUMENT MANUALLY !!!
+ * THIS FILE IS AUTOMATICALLY GENERATED BY THE TOOLS UNDER
+ * AutoDetect/tools/
+ */
+using System;
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class nsHZVerifier : nsVerifier {
+
+ static int[] m_cclass ;
+ static int[] m_states ;
+ static int m_stFactor ;
+ static String m_charset ;
+
+ public override int[] cclass() { return m_cclass ; }
+ public override int[] states() { return m_states ; }
+ public override int stFactor() { return m_stFactor ; }
+ public override String charset() { return m_charset ; }
+
+ public nsHZVerifier() {
+
+ m_cclass = new int[256/8] ;
+
+ m_cclass[0] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (1))) )))))) ;
+ m_cclass[1] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[2] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[3] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[4] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[5] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[6] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[7] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[8] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[9] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[10] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[11] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[12] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[13] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[14] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[15] = ((int)((( ((int)((( ((int)((( 0) << 4) | (2))) ) << 8) | (((int)(((5) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[16] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[17] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[18] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[19] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[20] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[21] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[22] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[23] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[24] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[25] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[26] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[27] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[28] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[29] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[30] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[31] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+
+
+
+ m_states = new int[6] ;
+
+ m_states[0] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eStart) << 4) | ( eStart))) ))) ) << 16) | ( ((int)((( ((int)(((eStart) << 4) | ( 3))) ) << 8) | ( ((int)(((eError) << 4) | (eStart))) )))))) ;
+ m_states[1] = ((int)((( ((int)((( ((int)((( eItsMe) << 4) | (eItsMe))) ) << 8) | (((int)(((eItsMe) << 4) | ( eItsMe))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[2] = ((int)((( ((int)((( ((int)((( eError) << 4) | ( 4))) ) << 8) | (((int)(((eStart) << 4) | ( eStart))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eItsMe) << 4) | (eItsMe))) )))))) ;
+ m_states[3] = ((int)((( ((int)((( ((int)((( eError) << 4) | ( 4))) ) << 8) | (((int)((( 5) << 4) | ( 5))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | ( 6))) ) << 8) | ( ((int)(((eError) << 4) | ( 5))) )))))) ;
+ m_states[4] = ((int)((( ((int)((( ((int)((( eError) << 4) | ( 4))) ) << 8) | (((int)(((eError) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)((( 4) << 4) | ( 4))) ) << 8) | ( ((int)(((eError) << 4) | ( 4))) )))))) ;
+ m_states[5] = ((int)((( ((int)((( ((int)((( eStart) << 4) | (eStart))) ) << 8) | (((int)(((eStart) << 4) | ( eStart))) ))) ) << 16) | ( ((int)((( ((int)(((eStart) << 4) | (eStart))) ) << 8) | ( ((int)(((eItsMe) << 4) | ( 4))) )))))) ;
+
+
+
+ m_charset = "HZ-GB-2312";
+ m_stFactor = 6;
+
+ }
+
+ public override bool isUCS2() { return false; }
+
+
+}
+
+
+} // namespace
diff --git a/src/External/NCharDet/nsICharsetDetectionObserver.cs b/src/External/NCharDet/nsICharsetDetectionObserver.cs
new file mode 100644
index 0000000..aa2630f
--- /dev/null
+++ b/src/External/NCharDet/nsICharsetDetectionObserver.cs
@@ -0,0 +1,48 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+using System;
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public interface nsICharsetDetectionObserver {
+
+ void Notify(String charset) ;
+}
+
+
+} // namespace
diff --git a/src/External/NCharDet/nsICharsetDetector.cs b/src/External/NCharDet/nsICharsetDetector.cs
new file mode 100644
index 0000000..b014b81
--- /dev/null
+++ b/src/External/NCharDet/nsICharsetDetector.cs
@@ -0,0 +1,49 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public interface nsICharsetDetector {
+
+ void Init (nsICharsetDetectionObserver observer) ;
+ bool DoIt (byte[] aBuf, int aLen, bool oDontFeedMe) ;
+ void Done () ;
+}
+
+} // namespace
diff --git a/src/External/NCharDet/nsISO2022CNVerifier.cs b/src/External/NCharDet/nsISO2022CNVerifier.cs
new file mode 100644
index 0000000..fb45f84
--- /dev/null
+++ b/src/External/NCharDet/nsISO2022CNVerifier.cs
@@ -0,0 +1,121 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+/*
+ * DO NOT EDIT THIS DOCUMENT MANUALLY !!!
+ * THIS FILE IS AUTOMATICALLY GENERATED BY THE TOOLS UNDER
+ * AutoDetect/tools/
+ */
+using System;
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class nsISO2022CNVerifier : nsVerifier {
+
+ static int[] m_cclass ;
+ static int[] m_states ;
+ static int m_stFactor ;
+ static String m_charset ;
+
+ public override int[] cclass() { return m_cclass ; }
+ public override int[] states() { return m_states ; }
+ public override int stFactor() { return m_stFactor ; }
+ public override String charset() { return m_charset ; }
+
+ public nsISO2022CNVerifier() {
+
+ m_cclass = new int[256/8] ;
+
+ m_cclass[0] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (2))) )))))) ;
+ m_cclass[1] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[2] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[3] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[4] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[5] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((3) << 4) | (0))) )))))) ;
+ m_cclass[6] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[7] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[8] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[9] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[10] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[11] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[12] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[13] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[14] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[15] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[16] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[17] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[18] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[19] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[20] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[21] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[22] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[23] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[24] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[25] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[26] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[27] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[28] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[29] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[30] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[31] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+
+
+
+ m_states = new int[8] ;
+
+ m_states[0] = ((int)((( ((int)((( ((int)((( eStart) << 4) | (eStart))) ) << 8) | (((int)(((eStart) << 4) | ( eStart))) ))) ) << 16) | ( ((int)((( ((int)(((eStart) << 4) | (eError))) ) << 8) | ( ((int)((( 3) << 4) | (eStart))) )))))) ;
+ m_states[1] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eStart))) )))))) ;
+ m_states[2] = ((int)((( ((int)((( ((int)((( eItsMe) << 4) | (eItsMe))) ) << 8) | (((int)(((eItsMe) << 4) | ( eItsMe))) ))) ) << 16) | ( ((int)((( ((int)(((eItsMe) << 4) | (eItsMe))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[3] = ((int)((( ((int)((( ((int)((( eError) << 4) | ( 4))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eItsMe))) ) << 8) | ( ((int)(((eItsMe) << 4) | (eItsMe))) )))))) ;
+ m_states[4] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eItsMe) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[5] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)((( 6) << 4) | ( 5))) )))))) ;
+ m_states[6] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eItsMe) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[7] = ((int)((( ((int)((( ((int)((( eStart) << 4) | (eError))) ) << 8) | (((int)(((eItsMe) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+
+
+
+ m_charset = "ISO-2022-CN";
+ m_stFactor = 9;
+
+ }
+
+ public override bool isUCS2() { return false; }
+
+
+}
+
+} // namespace
diff --git a/src/External/NCharDet/nsISO2022JPVerifier.cs b/src/External/NCharDet/nsISO2022JPVerifier.cs
new file mode 100644
index 0000000..3a58f46
--- /dev/null
+++ b/src/External/NCharDet/nsISO2022JPVerifier.cs
@@ -0,0 +1,119 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+/*
+ * DO NOT EDIT THIS DOCUMENT MANUALLY !!!
+ * THIS FILE IS AUTOMATICALLY GENERATED BY THE TOOLS UNDER
+ * AutoDetect/tools/
+ */
+using System;
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class nsISO2022JPVerifier : nsVerifier {
+
+ static int[] m_cclass ;
+ static int[] m_states ;
+ static int m_stFactor ;
+ static String m_charset ;
+
+ public override int[] cclass() { return m_cclass ; }
+ public override int[] states() { return m_states ; }
+ public override int stFactor() { return m_stFactor ; }
+ public override String charset() { return m_charset ; }
+
+ public nsISO2022JPVerifier() {
+
+ m_cclass = new int[256/8] ;
+
+ m_cclass[0] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (2))) )))))) ;
+ m_cclass[1] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[2] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[3] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[4] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 7))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[5] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (3))) )))))) ;
+ m_cclass[6] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[7] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[8] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (4))) ) << 8) | ( ((int)(((0) << 4) | (6))) )))))) ;
+ m_cclass[9] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (5))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[10] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[11] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[12] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[13] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[14] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[15] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[16] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[17] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[18] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[19] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[20] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[21] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[22] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[23] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[24] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[25] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[26] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[27] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[28] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[29] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[30] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[31] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+
+
+
+ m_states = new int[6] ;
+
+ m_states[0] = ((int)((( ((int)((( ((int)((( eStart) << 4) | (eStart))) ) << 8) | (((int)(((eStart) << 4) | ( eStart))) ))) ) << 16) | ( ((int)((( ((int)(((eStart) << 4) | (eError))) ) << 8) | ( ((int)((( 3) << 4) | (eStart))) )))))) ;
+ m_states[1] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[2] = ((int)((( ((int)((( ((int)((( eItsMe) << 4) | (eItsMe))) ) << 8) | (((int)(((eItsMe) << 4) | ( eItsMe))) ))) ) << 16) | ( ((int)((( ((int)(((eItsMe) << 4) | (eItsMe))) ) << 8) | ( ((int)(((eItsMe) << 4) | (eItsMe))) )))))) ;
+ m_states[3] = ((int)((( ((int)((( ((int)((( 4) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)((( 5) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[4] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eItsMe))) ) << 8) | (((int)(((eError) << 4) | ( eItsMe))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[5] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eItsMe) << 4) | ( eItsMe))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+
+
+
+ m_charset = "ISO-2022-JP";
+ m_stFactor = 8;
+
+ }
+
+ public override bool isUCS2() { return false; }
+
+
+}
+
+} // namespace
diff --git a/src/External/NCharDet/nsISO2022KRVerifier.cs b/src/External/NCharDet/nsISO2022KRVerifier.cs
new file mode 100644
index 0000000..1b39507
--- /dev/null
+++ b/src/External/NCharDet/nsISO2022KRVerifier.cs
@@ -0,0 +1,119 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+/*
+ * DO NOT EDIT THIS DOCUMENT MANUALLY !!!
+ * THIS FILE IS AUTOMATICALLY GENERATED BY THE TOOLS UNDER
+ * AutoDetect/tools/
+ */
+using System;
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class nsISO2022KRVerifier : nsVerifier {
+
+ static int[] m_cclass ;
+ static int[] m_states ;
+ static int m_stFactor ;
+ static String m_charset ;
+
+ public override int[] cclass() { return m_cclass ; }
+ public override int[] states() { return m_states ; }
+ public override int stFactor() { return m_stFactor ; }
+ public override String charset() { return m_charset ; }
+
+ public nsISO2022KRVerifier() {
+
+ m_cclass = new int[256/8] ;
+
+ m_cclass[0] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (2))) )))))) ;
+ m_cclass[1] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[2] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[3] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[4] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[5] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((4) << 4) | (0))) )))))) ;
+ m_cclass[6] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[7] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[8] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((5) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[9] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[10] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[11] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[12] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[13] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[14] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[15] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[16] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[17] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[18] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[19] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[20] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[21] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[22] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[23] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[24] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[25] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[26] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[27] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[28] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[29] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[30] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[31] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+
+
+
+ m_states = new int[5] ;
+
+ m_states[0] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eStart) << 4) | ( eStart))) ))) ) << 16) | ( ((int)((( ((int)(((eStart) << 4) | (eError))) ) << 8) | ( ((int)((( 3) << 4) | (eStart))) )))))) ;
+ m_states[1] = ((int)((( ((int)((( ((int)((( eItsMe) << 4) | (eItsMe))) ) << 8) | (((int)(((eItsMe) << 4) | ( eItsMe))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[2] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)((( 4) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eItsMe) << 4) | (eItsMe))) )))))) ;
+ m_states[3] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( 5))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[4] = ((int)((( ((int)((( ((int)((( eStart) << 4) | (eStart))) ) << 8) | (((int)(((eStart) << 4) | ( eStart))) ))) ) << 16) | ( ((int)((( ((int)(((eItsMe) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+
+
+
+ m_charset = "ISO-2022-KR";
+ m_stFactor = 6;
+
+ }
+
+ public override bool isUCS2() { return false; }
+
+
+}
+
+
+} // namespace
diff --git a/src/External/NCharDet/nsPSMDetector.cs b/src/External/NCharDet/nsPSMDetector.cs
new file mode 100644
index 0000000..6f9b8b0
--- /dev/null
+++ b/src/External/NCharDet/nsPSMDetector.cs
@@ -0,0 +1,428 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+using System;
+namespace org.mozilla.intl.chardet {
+//import java.lang.* ;
+
+public abstract class nsPSMDetector {
+
+ public const int ALL = 0 ;
+ public const int JAPANESE = 1 ;
+ public const int CHINESE = 2 ;
+ public const int SIMPLIFIED_CHINESE = 3 ;
+ public const int TRADITIONAL_CHINESE = 4 ;
+ public const int KOREAN = 5 ;
+
+ public const int NO_OF_LANGUAGES = 6 ;
+ public const int MAX_VERIFIERS = 16 ;
+
+ nsVerifier[] mVerifier ;
+ nsEUCStatistics[] mStatisticsData ;
+
+ nsEUCSampler mSampler = new nsEUCSampler() ;
+ byte[] mState = new byte[MAX_VERIFIERS] ;
+ int[] mItemIdx = new int[MAX_VERIFIERS] ;
+
+ int mItems ;
+ int mClassItems ;
+
+ protected bool mDone ;
+ protected bool mRunSampler ;
+ protected bool mClassRunSampler ;
+
+ public nsPSMDetector() {
+ initVerifiers( nsPSMDetector.ALL );
+ Reset() ;
+ }
+
+ public nsPSMDetector(int langFlag) {
+ initVerifiers(langFlag);
+ Reset() ;
+ }
+
+ public nsPSMDetector(int aItems, nsVerifier[] aVerifierSet,
+ nsEUCStatistics[] aStatisticsSet) {
+ mClassRunSampler = ( aStatisticsSet != null ) ;
+ mStatisticsData = aStatisticsSet ;
+ mVerifier = aVerifierSet ;
+
+ mClassItems = aItems ;
+ Reset() ;
+ }
+
+
+ public void Reset() {
+ mRunSampler = mClassRunSampler ;
+ mDone = false ;
+ mItems = mClassItems ;
+
+ for(int i=0; i<mItems; i++) {
+ mState[i] = 0;
+ mItemIdx[i] = i;
+ }
+
+ mSampler.Reset() ;
+ }
+
+ protected void initVerifiers(int currVerSet) {
+
+ //int idx = 0 ;
+ int currVerifierSet ;
+
+ if (currVerSet >=0 && currVerSet < NO_OF_LANGUAGES ) {
+ currVerifierSet = currVerSet ;
+ }
+ else {
+ currVerifierSet = nsPSMDetector.ALL ;
+ }
+
+ mVerifier = null ;
+ mStatisticsData = null ;
+
+ if ( currVerifierSet == nsPSMDetector.TRADITIONAL_CHINESE ) {
+
+ mVerifier = new nsVerifier[] {
+ new nsUTF8Verifier(),
+ new nsBIG5Verifier(),
+ new nsISO2022CNVerifier(),
+ new nsEUCTWVerifier(),
+ new nsCP1252Verifier(),
+ new nsUCS2BEVerifier(),
+ new nsUCS2LEVerifier()
+ };
+
+ mStatisticsData = new nsEUCStatistics[] {
+ null,
+ new Big5Statistics(),
+ null,
+ new EUCTWStatistics(),
+ null,
+ null,
+ null
+ };
+ }
+
+ //==========================================================
+ else if ( currVerifierSet == nsPSMDetector.KOREAN ) {
+
+ mVerifier = new nsVerifier[] {
+ new nsUTF8Verifier(),
+ new nsEUCKRVerifier(),
+ new nsISO2022KRVerifier(),
+ new nsCP1252Verifier(),
+ new nsUCS2BEVerifier(),
+ new nsUCS2LEVerifier()
+ };
+ }
+
+ //==========================================================
+ else if ( currVerifierSet == nsPSMDetector.SIMPLIFIED_CHINESE ) {
+
+ mVerifier = new nsVerifier[] {
+ new nsUTF8Verifier(),
+ new nsGB2312Verifier(),
+ new nsGB18030Verifier(),
+ new nsISO2022CNVerifier(),
+ new nsHZVerifier(),
+ new nsCP1252Verifier(),
+ new nsUCS2BEVerifier(),
+ new nsUCS2LEVerifier()
+ };
+ }
+
+ //==========================================================
+ else if ( currVerifierSet == nsPSMDetector.JAPANESE ) {
+
+ mVerifier = new nsVerifier[] {
+ new nsUTF8Verifier(),
+ new nsSJISVerifier(),
+ new nsEUCJPVerifier(),
+ new nsISO2022JPVerifier(),
+ new nsCP1252Verifier(),
+ new nsUCS2BEVerifier(),
+ new nsUCS2LEVerifier()
+ };
+ }
+ //==========================================================
+ else if ( currVerifierSet == nsPSMDetector.CHINESE ) {
+
+ mVerifier = new nsVerifier[] {
+ new nsUTF8Verifier(),
+ new nsGB2312Verifier(),
+ new nsGB18030Verifier(),
+ new nsBIG5Verifier(),
+ new nsISO2022CNVerifier(),
+ new nsHZVerifier(),
+ new nsEUCTWVerifier(),
+ new nsCP1252Verifier(),
+ new nsUCS2BEVerifier(),
+ new nsUCS2LEVerifier()
+ };
+
+ mStatisticsData = new nsEUCStatistics[] {
+ null,
+ new GB2312Statistics(),
+ null,
+ new Big5Statistics(),
+ null,
+ null,
+ new EUCTWStatistics(),
+ null,
+ null,
+ null
+ };
+ }
+
+ //==========================================================
+ else if ( currVerifierSet == nsPSMDetector.ALL ) {
+
+ mVerifier = new nsVerifier[] {
+ new nsUTF8Verifier(),
+ new nsSJISVerifier(),
+ new nsEUCJPVerifier(),
+ new nsISO2022JPVerifier(),
+ new nsEUCKRVerifier(),
+ new nsISO2022KRVerifier(),
+ new nsBIG5Verifier(),
+ new nsEUCTWVerifier(),
+ new nsGB2312Verifier(),
+ new nsGB18030Verifier(),
+ new nsISO2022CNVerifier(),
+ new nsHZVerifier(),
+ new nsCP1252Verifier(),
+ new nsUCS2BEVerifier(),
+ new nsUCS2LEVerifier()
+ };
+
+ mStatisticsData = new nsEUCStatistics[] {
+ null,
+ null,
+ new EUCJPStatistics(),
+ null,
+ new EUCKRStatistics(),
+ null,
+ new Big5Statistics(),
+ new EUCTWStatistics(),
+ new GB2312Statistics(),
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ };
+ }
+
+ mClassRunSampler = ( mStatisticsData != null ) ;
+ mClassItems = mVerifier.Length ;
+
+ }
+
+ public abstract void Report(String charset) ;
+
+ public bool HandleData(byte[] aBuf, int len) {
+
+
+ int i,j;
+ byte b, st;
+
+ for( i=0; i < len; i++) {
+ b = aBuf[i] ;
+
+ for (j=0; j < mItems; )
+ {
+ st = nsVerifier.getNextState( mVerifier[mItemIdx[j]],
+ b, mState[j]) ;
+//if (st != 0)
+//System.out.println( "state(0x" + Integer.toHexString(0xFF&b) +") =>"+ Integer.toHexString(st&0xFF)+ " " + mVerifier[mItemIdx[j]].charset());
+
+ if (st == nsVerifier.eItsMe) {
+
+//System.out.println( "eItsMe(0x" + Integer.toHexString(0xFF&b) +") =>"+ mVerifier[mItemIdx[j]].charset());
+
+ Report( mVerifier[mItemIdx[j]].charset() );
+ mDone = true ;
+ return mDone ;
+
+ } else if (st == nsVerifier.eError ) {
+
+//System.out.println( "eNotMe(0x" + Integer.toHexString(0xFF&b) +") =>"+ mVerifier[mItemIdx[j]].charset());
+ mItems--;
+ if (j < mItems ) {
+ mItemIdx[j] = mItemIdx[mItems];
+ mState[j] = mState[mItems];
+ }
+
+ } else {
+
+ mState[j++] = st ;
+
+ }
+ }
+
+ if ( mItems <= 1 ) {
+
+ if( 1 == mItems) {
+ Report( mVerifier[mItemIdx[0]].charset() );
+ }
+ mDone = true ;
+ return mDone ;
+
+ }
+ else {
+
+ int nonUCS2Num=0;
+ int nonUCS2Idx=0;
+
+ for(j=0; j<mItems; j++) {
+ if ( (!(mVerifier[mItemIdx[j]].isUCS2())) &&
+ (!(mVerifier[mItemIdx[j]].isUCS2())) )
+ {
+ nonUCS2Num++ ;
+ nonUCS2Idx = j ;
+ }
+ }
+
+ if (1 == nonUCS2Num) {
+ Report( mVerifier[mItemIdx[nonUCS2Idx]].charset() );
+ mDone = true ;
+ return mDone ;
+ }
+ }
+
+
+ } // End of for( i=0; i < len ...
+
+ if (mRunSampler)
+ Sample(aBuf, len);
+
+ return mDone ;
+ }
+
+
+ public void DataEnd() {
+
+ if (mDone == true)
+ return ;
+
+ if (mItems == 2) {
+ if ((mVerifier[mItemIdx[0]].charset()) == ("GB18030")) {
+ Report(mVerifier[mItemIdx[1]].charset()) ;
+ mDone = true ;
+ } else if ((mVerifier[mItemIdx[1]].charset()) == ("GB18030")) {
+ Report(mVerifier[mItemIdx[0]].charset()) ;
+ mDone = true ;
+ }
+ }
+
+ if (mRunSampler)
+ Sample(null, 0, true);
+ }
+
+ public void Sample(byte[] aBuf, int aLen) {
+ Sample(aBuf, aLen, false) ;
+ }
+
+ public void Sample(byte[] aBuf, int aLen, bool aLastChance)
+ {
+ int possibleCandidateNum = 0;
+ int j;
+ int eucNum=0 ;
+
+ for (j=0; j< mItems; j++) {
+ if (null != mStatisticsData[mItemIdx[j]])
+ eucNum++ ;
+ if ((!mVerifier[mItemIdx[j]].isUCS2()) &&
+ (!(mVerifier[mItemIdx[j]].charset() == "GB18030")))
+ possibleCandidateNum++ ;
+ }
+
+ mRunSampler = (eucNum > 1) ;
+
+ if (mRunSampler) {
+ mRunSampler = mSampler.Sample(aBuf, aLen);
+ if(((aLastChance && mSampler.GetSomeData()) ||
+ mSampler.EnoughData())
+ && (eucNum == possibleCandidateNum)) {
+ mSampler.CalFreq();
+
+ int bestIdx = -1;
+ int eucCnt=0;
+ float bestScore = 0.0f;
+ for(j = 0; j < mItems; j++) {
+ if((null != mStatisticsData[mItemIdx[j]]) &&
+ (!(mVerifier[mItemIdx[j]].charset() == "Big5")))
+ {
+ float score = mSampler.GetScore(
+ mStatisticsData[mItemIdx[j]].mFirstByteFreq(),
+ mStatisticsData[mItemIdx[j]].mFirstByteWeight(),
+ mStatisticsData[mItemIdx[j]].mSecondByteFreq(),
+ mStatisticsData[mItemIdx[j]].mSecondByteWeight() );
+//System.out.println("FequencyScore("+mVerifier[mItemIdx[j]].charset()+")= "+ score);
+ if(( 0 == eucCnt++) || (bestScore > score )) {
+ bestScore = score;
+ bestIdx = j;
+ } // if(( 0 == eucCnt++) || (bestScore > score ))
+ } // if(null != ...)
+ } // for
+ if (bestIdx >= 0)
+ {
+ Report( mVerifier[mItemIdx[bestIdx]].charset());
+ mDone = true;
+ }
+ } // if (eucNum == possibleCandidateNum)
+ } // if(mRunSampler)
+ }
+
+ public String[] getProbableCharsets() {
+
+ if (mItems <= 0) {
+ String[] nomatch = new String[1];
+ nomatch[0] = "nomatch" ;
+ return nomatch ;
+ }
+
+ String[] ret = new String[mItems] ;
+ for (int i=0; i<mItems; i++)
+ ret[i] = mVerifier[mItemIdx[i]].charset() ;
+ return ret ;
+ }
+
+}
+
+
+} // namespace
diff --git a/src/External/NCharDet/nsSJISVerifier.cs b/src/External/NCharDet/nsSJISVerifier.cs
new file mode 100644
index 0000000..156a64d
--- /dev/null
+++ b/src/External/NCharDet/nsSJISVerifier.cs
@@ -0,0 +1,116 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+/*
+ * DO NOT EDIT THIS DOCUMENT MANUALLY !!!
+ * THIS FILE IS AUTOMATICALLY GENERATED BY THE TOOLS UNDER
+ * AutoDetect/tools/
+ */
+using System;
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class nsSJISVerifier : nsVerifier {
+
+ static int[] m_cclass ;
+ static int[] m_states ;
+ static int m_stFactor ;
+ static String m_charset ;
+
+ public override int[] cclass() { return m_cclass ; }
+ public override int[] states() { return m_states ; }
+ public override int stFactor() { return m_stFactor ; }
+ public override String charset() { return m_charset ; }
+
+ public nsSJISVerifier() {
+
+ m_cclass = new int[256/8] ;
+
+ m_cclass[0] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (0))) )))))) ;
+ m_cclass[1] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[2] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[3] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[4] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[5] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[6] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[7] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[8] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[9] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[10] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[11] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[12] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[13] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[14] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[15] = ((int)((( ((int)((( ((int)((( 1) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[16] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[17] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[18] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[19] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[20] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (4))) )))))) ;
+ m_cclass[21] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[22] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[23] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[24] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[25] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[26] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[27] = ((int)((( ((int)((( ((int)((( 2) << 4) | (2))) ) << 8) | (((int)(((2) << 4) | ( 2))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[28] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[29] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 5))) ))) ) << 16) | ( ((int)((( ((int)(((5) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (3))) )))))) ;
+ m_cclass[30] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[31] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+
+
+
+ m_states = new int[3] ;
+
+ m_states[0] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)((( 3) << 4) | (eStart))) ) << 8) | ( ((int)(((eStart) << 4) | (eError))) )))))) ;
+ m_states[1] = ((int)((( ((int)((( ((int)((( eItsMe) << 4) | (eItsMe))) ) << 8) | (((int)(((eItsMe) << 4) | ( eItsMe))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[2] = ((int)((( ((int)((( ((int)((( eStart) << 4) | (eStart))) ) << 8) | (((int)(((eStart) << 4) | ( eStart))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eItsMe) << 4) | (eItsMe))) )))))) ;
+
+
+
+ m_charset = "Shift_JIS";
+ m_stFactor = 6;
+
+ }
+
+ public override bool isUCS2() { return false; }
+
+
+}
+
+} // namespace
diff --git a/src/External/NCharDet/nsUCS2BEVerifier.cs b/src/External/NCharDet/nsUCS2BEVerifier.cs
new file mode 100644
index 0000000..fe4be6f
--- /dev/null
+++ b/src/External/NCharDet/nsUCS2BEVerifier.cs
@@ -0,0 +1,120 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+/*
+ * DO NOT EDIT THIS DOCUMENT MANUALLY !!!
+ * THIS FILE IS AUTOMATICALLY GENERATED BY THE TOOLS UNDER
+ * AutoDetect/tools/
+ */
+using System;
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class nsUCS2BEVerifier : nsVerifier {
+
+ static int[] m_cclass ;
+ static int[] m_states ;
+ static int m_stFactor ;
+ static String m_charset ;
+
+ public override int[] cclass() { return m_cclass ; }
+ public override int[] states() { return m_states ; }
+ public override int stFactor() { return m_stFactor ; }
+ public override String charset() { return m_charset ; }
+
+ public nsUCS2BEVerifier() {
+
+ m_cclass = new int[256/8] ;
+
+ m_cclass[0] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[1] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((2) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (1))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[2] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[3] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[4] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[5] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (0))) )))))) ;
+ m_cclass[6] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[7] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[8] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[9] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[10] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[11] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[12] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[13] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[14] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[15] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[16] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[17] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[18] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[19] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[20] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[21] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[22] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[23] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[24] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[25] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[26] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[27] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[28] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[29] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[30] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[31] = ((int)((( ((int)((( ((int)((( 5) << 4) | (4))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+
+
+
+ m_states = new int[7] ;
+
+ m_states[0] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)((( 3) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | ( 7))) ) << 8) | ( ((int)((( 7) << 4) | ( 5))) )))))) ;
+ m_states[1] = ((int)((( ((int)((( ((int)((( eItsMe) << 4) | (eItsMe))) ) << 8) | (((int)(((eItsMe) << 4) | ( eItsMe))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[2] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)((( 6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)((( 6) << 4) | ( 6))) ) << 8) | ( ((int)(((eItsMe) << 4) | (eItsMe))) )))))) ;
+ m_states[3] = ((int)((( ((int)((( ((int)((( 6) << 4) | ( 6))) ) << 8) | (((int)(((eItsMe) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)((( 6) << 4) | ( 6))) ) << 8) | ( ((int)((( 6) << 4) | ( 6))) )))))) ;
+ m_states[4] = ((int)((( ((int)((( ((int)((( eError) << 4) | ( 7))) ) << 8) | (((int)((( 7) << 4) | ( 5))) ))) ) << 16) | ( ((int)((( ((int)((( 6) << 4) | ( 6))) ) << 8) | ( ((int)((( 6) << 4) | ( 6))) )))))) ;
+ m_states[5] = ((int)((( ((int)((( ((int)((( 6) << 4) | ( 6))) ) << 8) | (((int)((( 6) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)((( 6) << 4) | ( 6))) ) << 8) | ( ((int)((( 8) << 4) | ( 5))) )))))) ;
+ m_states[6] = ((int)((( ((int)((( ((int)((( eStart) << 4) | (eStart))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)((( 6) << 4) | ( 6))) ) << 8) | ( ((int)((( 6) << 4) | ( 6))) )))))) ;
+
+
+
+ m_charset = "UTF-16BE";
+ m_stFactor = 6;
+
+ }
+
+ public override bool isUCS2() { return true; }
+
+
+}
+
+} // namespace
diff --git a/src/External/NCharDet/nsUCS2LEVerifier.cs b/src/External/NCharDet/nsUCS2LEVerifier.cs
new file mode 100644
index 0000000..7c55bf0
--- /dev/null
+++ b/src/External/NCharDet/nsUCS2LEVerifier.cs
@@ -0,0 +1,120 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+/*
+ * DO NOT EDIT THIS DOCUMENT MANUALLY !!!
+ * THIS FILE IS AUTOMATICALLY GENERATED BY THE TOOLS UNDER
+ * AutoDetect/tools/
+ */
+using System;
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class nsUCS2LEVerifier : nsVerifier {
+
+ static int[] m_cclass ;
+ static int[] m_states ;
+ static int m_stFactor ;
+ static String m_charset ;
+
+ public override int[] cclass() { return m_cclass ; }
+ public override int[] states() { return m_states ; }
+ public override int stFactor() { return m_stFactor ; }
+ public override String charset() { return m_charset ; }
+
+ public nsUCS2LEVerifier() {
+
+ m_cclass = new int[256/8] ;
+
+ m_cclass[0] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[1] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((2) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (1))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[2] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[3] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[4] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[5] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((3) << 4) | (3))) ) << 8) | ( ((int)(((3) << 4) | (0))) )))))) ;
+ m_cclass[6] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[7] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[8] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[9] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[10] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[11] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[12] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[13] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[14] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[15] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[16] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[17] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[18] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[19] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[20] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[21] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[22] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[23] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[24] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[25] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[26] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[27] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[28] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[29] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[30] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[31] = ((int)((( ((int)((( ((int)((( 5) << 4) | (4))) ) << 8) | (((int)(((0) << 4) | ( 0))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (0))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+
+
+
+ m_states = new int[7] ;
+
+ m_states[0] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)((( 3) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)((( 6) << 4) | ( 7))) ) << 8) | ( ((int)((( 6) << 4) | ( 6))) )))))) ;
+ m_states[1] = ((int)((( ((int)((( ((int)((( eItsMe) << 4) | (eItsMe))) ) << 8) | (((int)(((eItsMe) << 4) | ( eItsMe))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[2] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eItsMe))) ) << 8) | (((int)(((eError) << 4) | ( 5))) ))) ) << 16) | ( ((int)((( ((int)((( 5) << 4) | ( 5))) ) << 8) | ( ((int)(((eItsMe) << 4) | (eItsMe))) )))))) ;
+ m_states[3] = ((int)((( ((int)((( ((int)((( 6) << 4) | ( 6))) ) << 8) | (((int)(((eError) << 4) | ( 5))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | ( 5))) ) << 8) | ( ((int)((( 5) << 4) | ( 5))) )))))) ;
+ m_states[4] = ((int)((( ((int)((( ((int)((( eError) << 4) | ( 5))) ) << 8) | (((int)((( 5) << 4) | ( 5))) ))) ) << 16) | ( ((int)((( ((int)((( 8) << 4) | ( 8))) ) << 8) | ( ((int)((( 6) << 4) | ( 7))) )))))) ;
+ m_states[5] = ((int)((( ((int)((( ((int)((( 5) << 4) | ( 5))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | ( 5))) ) << 8) | ( ((int)((( 5) << 4) | ( 5))) )))))) ;
+ m_states[6] = ((int)((( ((int)((( ((int)((( eStart) << 4) | (eStart))) ) << 8) | (((int)(((eError) << 4) | ( 5))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | ( 5))) ) << 8) | ( ((int)((( 5) << 4) | ( 5))) )))))) ;
+
+
+
+ m_charset = "UTF-16LE";
+ m_stFactor = 6;
+
+ }
+
+ public override bool isUCS2() { return true; }
+
+
+}
+
+} // namespace
diff --git a/src/External/NCharDet/nsUTF8Verifier.cs b/src/External/NCharDet/nsUTF8Verifier.cs
new file mode 100644
index 0000000..8bcb378
--- /dev/null
+++ b/src/External/NCharDet/nsUTF8Verifier.cs
@@ -0,0 +1,140 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+/*
+ * DO NOT EDIT THIS DOCUMENT MANUALLY !!!
+ * THIS FILE IS AUTOMATICALLY GENERATED BY THE TOOLS UNDER
+ * AutoDetect/tools/
+ */
+using System;
+namespace org.mozilla.intl.chardet {
+
+//import java.lang.* ;
+
+public class nsUTF8Verifier : nsVerifier {
+
+ static int[] m_cclass ;
+ static int[] m_states ;
+ static int m_stFactor ;
+ static String m_charset ;
+
+ public override int[] cclass() { return m_cclass ; }
+ public override int[] states() { return m_states ; }
+ public override int stFactor() { return m_stFactor ; }
+ public override String charset() { return m_charset ; }
+
+ public nsUTF8Verifier() {
+
+ m_cclass = new int[256/8] ;
+
+ m_cclass[0] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[1] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[2] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[3] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((0) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[4] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[5] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[6] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[7] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[8] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[9] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[10] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[11] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[12] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[13] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[14] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[15] = ((int)((( ((int)((( ((int)((( 1) << 4) | (1))) ) << 8) | (((int)(((1) << 4) | ( 1))) ))) ) << 16) | ( ((int)((( ((int)(((1) << 4) | (1))) ) << 8) | ( ((int)(((1) << 4) | (1))) )))))) ;
+ m_cclass[16] = ((int)((( ((int)((( ((int)((( 3) << 4) | (3))) ) << 8) | (((int)(((3) << 4) | ( 3))) ))) ) << 16) | ( ((int)((( ((int)(((2) << 4) | (2))) ) << 8) | ( ((int)(((2) << 4) | (2))) )))))) ;
+ m_cclass[17] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[18] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[19] = ((int)((( ((int)((( ((int)((( 4) << 4) | (4))) ) << 8) | (((int)(((4) << 4) | ( 4))) ))) ) << 16) | ( ((int)((( ((int)(((4) << 4) | (4))) ) << 8) | ( ((int)(((4) << 4) | (4))) )))))) ;
+ m_cclass[20] = ((int)((( ((int)((( ((int)((( 5) << 4) | (5))) ) << 8) | (((int)(((5) << 4) | ( 5))) ))) ) << 16) | ( ((int)((( ((int)(((5) << 4) | (5))) ) << 8) | ( ((int)(((5) << 4) | (5))) )))))) ;
+ m_cclass[21] = ((int)((( ((int)((( ((int)((( 5) << 4) | (5))) ) << 8) | (((int)(((5) << 4) | ( 5))) ))) ) << 16) | ( ((int)((( ((int)(((5) << 4) | (5))) ) << 8) | ( ((int)(((5) << 4) | (5))) )))))) ;
+ m_cclass[22] = ((int)((( ((int)((( ((int)((( 5) << 4) | (5))) ) << 8) | (((int)(((5) << 4) | ( 5))) ))) ) << 16) | ( ((int)((( ((int)(((5) << 4) | (5))) ) << 8) | ( ((int)(((5) << 4) | (5))) )))))) ;
+ m_cclass[23] = ((int)((( ((int)((( ((int)((( 5) << 4) | (5))) ) << 8) | (((int)(((5) << 4) | ( 5))) ))) ) << 16) | ( ((int)((( ((int)(((5) << 4) | (5))) ) << 8) | ( ((int)(((5) << 4) | (5))) )))))) ;
+ m_cclass[24] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((0) << 4) | (0))) )))))) ;
+ m_cclass[25] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (6))) )))))) ;
+ m_cclass[26] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (6))) )))))) ;
+ m_cclass[27] = ((int)((( ((int)((( ((int)((( 6) << 4) | (6))) ) << 8) | (((int)(((6) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)(((6) << 4) | (6))) ) << 8) | ( ((int)(((6) << 4) | (6))) )))))) ;
+ m_cclass[28] = ((int)((( ((int)((( ((int)((( 8) << 4) | (8))) ) << 8) | (((int)(((8) << 4) | ( 8))) ))) ) << 16) | ( ((int)((( ((int)(((8) << 4) | (8))) ) << 8) | ( ((int)(((8) << 4) | (7))) )))))) ;
+ m_cclass[29] = ((int)((( ((int)((( ((int)((( 8) << 4) | (8))) ) << 8) | (((int)(((9) << 4) | ( 8))) ))) ) << 16) | ( ((int)((( ((int)(((8) << 4) | (8))) ) << 8) | ( ((int)(((8) << 4) | (8))) )))))) ;
+ m_cclass[30] = ((int)((( ((int)((( ((int)((( 11) << 4) | (11))) ) << 8) | (((int)(((11) << 4) | ( 11))) ))) ) << 16) | ( ((int)((( ((int)(((11) << 4) | (11))) ) << 8) | ( ((int)(((11) << 4) | (10))) )))))) ;
+ m_cclass[31] = ((int)((( ((int)((( ((int)((( 0) << 4) | (0))) ) << 8) | (((int)(((15) << 4) | ( 14))) ))) ) << 16) | ( ((int)((( ((int)(((13) << 4) | (13))) ) << 8) | ( ((int)(((13) << 4) | (12))) )))))) ;
+
+
+
+ m_states = new int[26] ;
+
+ m_states[0] = ((int)((( ((int)((( ((int)((( 10) << 4) | ( 12))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eStart) << 4) | (eError))) )))))) ;
+ m_states[1] = ((int)((( ((int)((( ((int)((( 3) << 4) | ( 4))) ) << 8) | (((int)((( 5) << 4) | ( 6))) ))) ) << 16) | ( ((int)((( ((int)((( 7) << 4) | ( 8))) ) << 8) | ( ((int)((( 11) << 4) | ( 9))) )))))) ;
+ m_states[2] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[3] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[4] = ((int)((( ((int)((( ((int)((( eItsMe) << 4) | (eItsMe))) ) << 8) | (((int)(((eItsMe) << 4) | ( eItsMe))) ))) ) << 16) | ( ((int)((( ((int)(((eItsMe) << 4) | (eItsMe))) ) << 8) | ( ((int)(((eItsMe) << 4) | (eItsMe))) )))))) ;
+ m_states[5] = ((int)((( ((int)((( ((int)((( eItsMe) << 4) | (eItsMe))) ) << 8) | (((int)(((eItsMe) << 4) | ( eItsMe))) ))) ) << 16) | ( ((int)((( ((int)(((eItsMe) << 4) | (eItsMe))) ) << 8) | ( ((int)(((eItsMe) << 4) | (eItsMe))) )))))) ;
+ m_states[6] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)((( 5) << 4) | ( 5))) ))) ) << 16) | ( ((int)((( ((int)((( 5) << 4) | ( 5))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[7] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[8] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)((( 5) << 4) | ( 5))) ))) ) << 16) | ( ((int)((( ((int)((( 5) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[9] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[10] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)((( 7) << 4) | ( 7))) ))) ) << 16) | ( ((int)((( ((int)((( 7) << 4) | ( 7))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[11] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[12] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)((( 7) << 4) | ( 7))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[13] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[14] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)((( 9) << 4) | ( 9))) ))) ) << 16) | ( ((int)((( ((int)((( 9) << 4) | ( 9))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[15] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[16] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)((( 9) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[17] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[18] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)((( 12) << 4) | ( 12))) ))) ) << 16) | ( ((int)((( ((int)((( 12) << 4) | ( 12))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[19] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[20] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)((( 12) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[21] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[22] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( 12))) ))) ) << 16) | ( ((int)((( ((int)((( 12) << 4) | ( 12))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[23] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[24] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eStart) << 4) | ( eStart))) ))) ) << 16) | ( ((int)((( ((int)(((eStart) << 4) | (eStart))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+ m_states[25] = ((int)((( ((int)((( ((int)((( eError) << 4) | (eError))) ) << 8) | (((int)(((eError) << 4) | ( eError))) ))) ) << 16) | ( ((int)((( ((int)(((eError) << 4) | (eError))) ) << 8) | ( ((int)(((eError) << 4) | (eError))) )))))) ;
+
+
+
+ m_charset = "UTF-8";
+ m_stFactor = 16;
+
+ }
+
+ public override bool isUCS2() { return false; }
+
+
+}
+
+
+} // namespace
diff --git a/src/External/NCharDet/nsVerifier.cs b/src/External/NCharDet/nsVerifier.cs
new file mode 100644
index 0000000..10c144a
--- /dev/null
+++ b/src/External/NCharDet/nsVerifier.cs
@@ -0,0 +1,81 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is mozilla.org code.
+*
+* The Initial Developer of the Original Code is
+* Netscape Communications Corporation.
+* Portions created by the Initial Developer are Copyright (C) 1998
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Craig Dunn <craig dot dunn at conceptdevelopment dot net>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either of the GNU General Public License Version 2 or later (the "GPL"),
+* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+using System;
+namespace org.mozilla.intl.chardet {
+
+////import java.lang.* ;
+
+public abstract class nsVerifier { //abstract
+
+ public const byte eStart = (byte)0;
+ public const byte eError = (byte)1;
+ public const byte eItsMe = (byte)2;
+ public const int eidxSft4bits = 3;
+ public const int eSftMsk4bits = 7;
+ public const int eBitSft4bits = 2;
+ public const int eUnitMsk4bits = 0x0000000F;
+
+ public nsVerifier() {
+ }
+
+ public abstract String charset() ;
+ public abstract int stFactor() ;
+ public abstract int[] cclass() ;
+ public abstract int[] states() ;
+
+ public abstract bool isUCS2() ;
+
+ public static byte getNextState(nsVerifier v, byte b, byte s) {
+
+ return (byte) ( 0xFF &
+ (((v.states()[((
+ (s*v.stFactor()+(((v.cclass()[((b&0xFF)>>nsVerifier.eidxSft4bits)])
+ >> ((b & nsVerifier.eSftMsk4bits) << nsVerifier.eBitSft4bits))
+ & nsVerifier.eUnitMsk4bits ))&0xFF)
+ >> nsVerifier.eidxSft4bits) ]) >> (((
+ (s*v.stFactor()+(((v.cclass()[((b&0xFF)>>nsVerifier.eidxSft4bits)])
+ >> ((b & nsVerifier.eSftMsk4bits) << nsVerifier.eBitSft4bits))
+ & nsVerifier.eUnitMsk4bits ))&0xFF)
+ & nsVerifier.eSftMsk4bits) << nsVerifier.eBitSft4bits)) & nsVerifier.eUnitMsk4bits )
+ ) ;
+
+ }
+
+
+}
+
+} // namespace
diff --git a/src/Glade/AboutDialog.glade b/src/Glade/AboutDialog.glade
index d5595f9..22aea1e 100644
--- a/src/Glade/AboutDialog.glade
+++ b/src/Glade/AboutDialog.glade
@@ -11,6 +11,7 @@
<property name="skip_taskbar_hint">True</property>
<property name="skip_pager_hint">True</property>
<property name="has_separator">False</property>
+ <property name="program_name">Gnome Subtitles</property>
<property name="copyright">Copyright © 2006-2009 Pedro Castro</property>
<property name="comments" translatable="yes">Video subtitling for the GNOME desktop</property>
<property name="website">http://gnome-subtitles.sf.net</property>
diff --git a/src/GnomeSubtitles/Dialog/AboutDialog.cs b/src/GnomeSubtitles/Dialog/AboutDialog.cs
index fd594bb..95cab41 100644
--- a/src/GnomeSubtitles/Dialog/AboutDialog.cs
+++ b/src/GnomeSubtitles/Dialog/AboutDialog.cs
@@ -56,8 +56,6 @@ public class AboutDialog : GladeDialog {
}
private void SetInfo () {
- dialog.ProgramName = "Gnome Subtitles";
- dialog.Comments += "\n\nUsing SubLib " + Base.ExecutionContext.SubLibVersion;
dialog.Version = Base.ExecutionContext.Version;
dialog.Logo = new Gdk.Pixbuf(null, logoFilename);
}
diff --git a/src/GnomeSubtitles/Execution/BugReporter.cs b/src/GnomeSubtitles/Execution/BugReporter.cs
index 07184c7..a0f07e8 100644
--- a/src/GnomeSubtitles/Execution/BugReporter.cs
+++ b/src/GnomeSubtitles/Execution/BugReporter.cs
@@ -63,7 +63,6 @@ public class BugReporter {
private static string GetBugInfo (string message) {
return "Gnome Subtitles version: " + Base.ExecutionContext.Version + "\n"
- + "SubLib version: " + Base.ExecutionContext.SubLibVersion + "\n"
+ "GtkSharp version: " + Base.ExecutionContext.GtkSharpVersion + "\n"
+ "GladeSharp version: " + Base.ExecutionContext.GladeSharpVersion + "\n"
+ "GConfSharp version: " + Base.ExecutionContext.GConfSharpVersion + "\n\n"
diff --git a/src/GnomeSubtitles/Execution/ExecutionContext.cs b/src/GnomeSubtitles/Execution/ExecutionContext.cs
index e6837a5..951274b 100644
--- a/src/GnomeSubtitles/Execution/ExecutionContext.cs
+++ b/src/GnomeSubtitles/Execution/ExecutionContext.cs
@@ -1,6 +1,6 @@
/*
* This file is part of Gnome Subtitles.
- * Copyright (C) 2006-2008 Pedro Castro
+ * Copyright (C) 2006-2009 Pedro Castro
*
* Gnome Subtitles is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,11 +28,9 @@ public class ExecutionContext {
private bool initialized = false;
private bool running = false;
- #region Constant strings
+ /* Constant strings */
private const string applicationName = "Gnome Subtitles";
private const string applicationID = "gnome-subtitles";
- private const string subLibAssemblyName = "sublib";
- #endregion
private string[] args = null;
@@ -40,7 +38,7 @@ public class ExecutionContext {
this.args = args;
}
- #region Public properties
+ /* Public properties */
public bool Initialized {
get { return initialized; }
@@ -62,10 +60,6 @@ public class ExecutionContext {
get { return RemoveTrailingZeros(Assembly.GetExecutingAssembly().GetName().Version.ToString()); }
}
- public string SubLibVersion {
- get { return RemoveTrailingZeros(Assembly.ReflectionOnlyLoad(subLibAssemblyName).GetName().Version.ToString()); }
- }
-
public string GtkSharpVersion {
get { return RemoveTrailingZeros(Assembly.Load("gtk-sharp").GetName().Version.ToString()); }
}
@@ -87,9 +81,8 @@ public class ExecutionContext {
get { return applicationID; }
}
- #endregion
-
- #region Public methods
+
+ /* Public methods */
public void InitApplication () {
if (!initialized) {
@@ -111,9 +104,8 @@ public class ExecutionContext {
Application.Quit();
}
- #endregion
-
- #region Private methods
+
+ /* Private methods */
private string RemoveTrailingZeros (string version) {
while (version.EndsWith(".0")) {
@@ -122,8 +114,6 @@ public class ExecutionContext {
return version;
}
- #endregion
-
}
}
diff --git a/src/Makefile.am b/src/Makefile.am
index 7859b2d..6fda662 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,6 +14,7 @@ libgstreamer_playbin_so_LDFLAGS = $(gstreamer_LIBS) -lgstinterfaces-0.10 -shared
GS_SOURCES = \
$(srcdir)/External/GStreamerPlaybin/*.cs \
+ $(srcdir)/External/NCharDet/*.cs \
$(srcdir)/GnomeSubtitles/Core/*.cs \
$(srcdir)/GnomeSubtitles/Core/Command/*.cs \
$(srcdir)/GnomeSubtitles/Dialog/*.cs \
@@ -23,7 +24,16 @@ GS_SOURCES = \
$(srcdir)/GnomeSubtitles/Ui/Edit/*.cs \
$(srcdir)/GnomeSubtitles/Ui/VideoPreview/*.cs \
$(srcdir)/GnomeSubtitles/Ui/VideoPreview/Exceptions/*.cs \
- $(srcdir)/GnomeSubtitles/Ui/View/*.cs
+ $(srcdir)/GnomeSubtitles/Ui/View/*.cs \
+ $(srcdir)/SubLib/Core/*.cs \
+ $(srcdir)/SubLib/Core/Domain/*.cs \
+ $(srcdir)/SubLib/Core/Search/*.cs \
+ $(srcdir)/SubLib/Core/Timing/*.cs \
+ $(srcdir)/SubLib/Exceptions/*.cs \
+ $(srcdir)/SubLib/IO/*.cs \
+ $(srcdir)/SubLib/IO/Input/*.cs \
+ $(srcdir)/SubLib/IO/Output/*.cs \
+ $(srcdir)/SubLib/IO/SubtitleFormats/*.cs
GS_RESOURCES = \
$(srcdir)/Glade/AboutDialog.glade \
diff --git a/src/SubLib/ChangeLog b/src/SubLib/ChangeLog
new file mode 100644
index 0000000..3e442be
--- /dev/null
+++ b/src/SubLib/ChangeLog
@@ -0,0 +1,2084 @@
+2009-05-31 00:47 noup
+
+ * src/SubLib/Core/Domain/Times.cs: Allow to clone the times.
+
+2009-05-23 11:56 noup
+
+ * sublib.mdp: Changed default build target, added source files.
+
+2009-05-23 11:55 noup
+
+ * src/SubLib/IO/Input/SubtitleParser.cs,
+ src/SubLib/IO/Output/SubtitleOutput.cs: Updated after a refactor
+ in the utility classes.
+
+2009-05-23 11:55 noup
+
+ * src/SubLib/Core/Domain/Subtitle.cs: Updated after a refactor in
+ the utility classes.
+
+2009-05-23 11:55 noup
+
+ * src/SubLib/Core/Timing/SynchronizeOperator.cs: Added
+ synchronization methods.
+
+2009-05-23 11:54 noup
+
+ * src/SubLib/Core/Timing/AdjustOperator.cs: Updated after a
+ refactor in the utility classes.
+
+2009-05-23 11:53 noup
+
+ * src/SubLib/Core/Timing/SyncUtil.cs: Utilitary methods to use in
+ when synchronizing subtitles.
+
+2009-05-23 11:53 noup
+
+ * src/SubLib/Core/Timing/TimingUtil.cs: Class with timing util
+ methods (from SyncUtil).
+
+2009-05-23 11:51 noup
+
+ * src/SubLib/Core/Domain/SyncPoints.cs: Improved sync points
+ handling.
+
+2008-12-31 01:28 noup
+
+ * src/SubLib/Core/Domain/SyncPoint.cs,
+ src/SubLib/Core/Domain/SyncPoints.cs,
+ src/SubLib/Core/Domain/Timing.cs, sublib.mdp: Added objects that
+ allow to set sync points, to be used with the
+ Timings Synchronization operator.
+
+2008-12-14 22:31 noup
+
+ * TODO: Added TODO file.
+
+2008-10-04 23:13 noup
+
+ * src/Executable/Executable.cs, src/Makefile.am,
+ src/SubLib/IO/Input/SubtitleParser.cs,
+ src/SubLib/IO/Output/SubtitleOutput.cs, sublib.mdp: Separated
+ operations to their individual classes and namespaces (Search and
+ Timings).
+
+2008-10-04 23:12 noup
+
+ * src/SubLib/Core/Domain/Subtitle.cs,
+ src/SubLib/Core/Domain/SubtitleSearchOptions.cs,
+ src/SubLib/Core/Domain/SubtitleSearchResults.cs,
+ src/SubLib/Core/Domain/Subtitles.cs, src/SubLib/Core/Search,
+ src/SubLib/Core/Search/SearchOperator.cs,
+ src/SubLib/Core/Search/SubtitleSearchOptions.cs,
+ src/SubLib/Core/Search/SubtitleSearchResults.cs,
+ src/SubLib/Core/Synchronization.cs,
+ src/SubLib/Core/Timing/AdjustOperator.cs,
+ src/SubLib/Core/Timing/FrameRateOperator.cs,
+ src/SubLib/Core/Timing/ShiftOperator.cs,
+ src/SubLib/Core/Timing/SyncUtil.cs,
+ src/SubLib/Core/Timing/SynchronizeOperator.cs,
+ src/SubLib/Core/Timing/Util.cs, src/SubLib/Core/Util.cs:
+ Separated operations to their individual classes and namespaces
+ (Search and Timings).
+
+2008-10-04 20:57 noup
+
+ * src/SubLib/Core/Timing/Util.cs: Util has timing utility methods.
+
+2008-10-04 20:57 noup
+
+ * src/SubLib/Core/Timing: Namespace to hold timing operations.
+
+2008-10-04 20:55 noup
+
+ * src/SubLib/Core/Util.cs: Renamed as this is a utilitary class.
+
+2008-09-21 14:02 noup
+
+ * src/SubLib/IO/SubtitleFormats/SubtitleFormatSubRip.cs: Improved
+ SubRip parsing to allow blank lines (fixes bug #2116768).
+ Fixed bug with blank lines being filled with the number 0.
+
+2008-09-09 23:35 noup
+
+ * src/Makefile.am, src/SubLib/Core/Domain/Subtitles.cs,
+ src/SubLib/Exceptions/EncodingNotSupportedException.cs,
+ src/SubLib/Exceptions/UnknownEncodingException.cs,
+ src/SubLib/Exceptions/UnknownSubtitleFormatException.cs,
+ src/SubLib/IO/Input/SubtitleInput.cs,
+ src/SubLib/IO/Output/SubtitleOutput.cs,
+ src/SubLib/IO/SubtitleFormats/BuiltInSubtitleFormats.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatSofni.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatSubCreator1x.cs,
+ sublib.mdp: Major refactoring - namespace and directory structure
+ changes.
+
+2008-09-09 23:25 noup
+
+ * src/Executable/Executable.cs,
+ src/SubLib/Core/Domain/SubtitleProperties.cs,
+ src/SubLib/Core/SubtitleFactory.cs,
+ src/SubLib/Core/SubtitleSaver.cs,
+ src/SubLib/Core/Translations.cs, src/SubLib/Exception,
+ src/SubLib/Exceptions,
+ src/SubLib/Exceptions/EncodingNotSupportedException.cs,
+ src/SubLib/Exceptions/UnknownEncodingException.cs,
+ src/SubLib/Exceptions/UnknownSubtitleFormatException.cs,
+ src/SubLib/IO/FileInputOutput.cs,
+ src/SubLib/IO/Input/ParsingProperties.cs,
+ src/SubLib/IO/Input/PlainTextParser.cs,
+ src/SubLib/IO/Input/SubtitleInput.cs,
+ src/SubLib/IO/Input/SubtitleParser.cs,
+ src/SubLib/IO/Output/SubtitleOutput.cs,
+ src/SubLib/IO/Output/VerboseConsole.cs,
+ src/SubLib/IO/SubtitleFormats/BuiltInSubtitleFormats.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormat.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatAQTitle.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatAdobeEncoreDVD.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatAdvancedSubStationAlpha.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatDKSSubtitleFormat.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatKaraokeLyricsLRC.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatKaraokeLyricsVKT.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatMPSub.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatMPlayer.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatMPlayer2.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatMacSUB.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatMicroDVD.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatPanimator.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatPhoenixJapanimationSociety.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatPowerDivX.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatSubRip.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatSubStationAlpha.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatSubViewer1.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatSubViewer2.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatViPlaySubtitleFile.cs:
+ Major refactoring
+
+2008-09-09 00:07 noup
+
+ * src/Executable/Executable.cs,
+ src/SubLib/Core/Domain/SubtitleTypeInfo.cs,
+ src/SubLib/Core/SubtitleFactory.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatAQTitle.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatMacSUB.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatSofni.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatSubCreator1x.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatViPlaySubtitleFile.cs,
+ sublib.mdp, sublib.mds: Major refactoring
+
+2008-09-08 23:58 noup
+
+ * src/SubLib/Core/Domain/Enumerations.cs,
+ src/SubLib/Core/Domain/FileProperties.cs,
+ src/SubLib/Core/Domain/Frames.cs,
+ src/SubLib/Core/Domain/Headers.cs,
+ src/SubLib/Core/Domain/IncompleteSubtitle.cs,
+ src/SubLib/Core/Domain/IncompleteSubtitleCollection.cs,
+ src/SubLib/Core/Domain/Style.cs,
+ src/SubLib/Core/Domain/Subtitle.cs,
+ src/SubLib/Core/Domain/SubtitleCollection.cs,
+ src/SubLib/Core/Domain/SubtitleConstants.cs,
+ src/SubLib/Core/Domain/SubtitleHeaders.cs,
+ src/SubLib/Core/Domain/SubtitleProperties.cs,
+ src/SubLib/Core/Domain/SubtitleSearchOptions.cs,
+ src/SubLib/Core/Domain/SubtitleSearchResults.cs,
+ src/SubLib/Core/Domain/SubtitleText.cs,
+ src/SubLib/Core/Domain/SubtitleTypeInfo.cs,
+ src/SubLib/Core/Domain/Subtitles.cs,
+ src/SubLib/Core/Domain/Times.cs,
+ src/SubLib/Core/MatchEvaluationCounter.cs,
+ src/SubLib/Core/SubtitleFactory.cs,
+ src/SubLib/Core/SubtitleSaver.cs,
+ src/SubLib/Core/Synchronization.cs,
+ src/SubLib/Core/Translations.cs,
+ src/SubLib/Exception/EncodingNotSupportedException.cs,
+ src/SubLib/Exception/UnknownEncodingException.cs,
+ src/SubLib/Exception/UnknownSubtitleFormatException.cs,
+ src/SubLib/IO/FileInputOutput.cs,
+ src/SubLib/IO/Input/ParsingProperties.cs,
+ src/SubLib/IO/Input/PlainTextParser.cs,
+ src/SubLib/IO/Input/SubtitleInput.cs,
+ src/SubLib/IO/Input/SubtitleParser.cs,
+ src/SubLib/IO/Output/SubtitleOutput.cs,
+ src/SubLib/IO/Output/VerboseConsole.cs,
+ src/SubLib/IO/SubtitleFormats/BuiltInSubtitleFormats.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormat.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatAdobeEncoreDVD.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatAdvancedSubStationAlpha.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatDKSSubtitleFormat.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatKaraokeLyricsLRC.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatKaraokeLyricsVKT.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatMPSub.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatMPlayer.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatMPlayer2.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatMicroDVD.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatPanimator.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatPhoenixJapanimationSociety.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatPowerDivX.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatSubRip.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatSubStationAlpha.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatSubViewer1.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatSubViewer2.cs: Major
+ refactoring
+
+2008-09-08 23:51 noup
+
+ * src/SubLib/IO/BuiltInSubtitleFormats.cs,
+ src/SubLib/IO/Input/ParsingProperties.cs,
+ src/SubLib/IO/Input/PlainTextParser.cs,
+ src/SubLib/IO/Input/SubtitleInput.cs,
+ src/SubLib/IO/Input/SubtitleParser.cs,
+ src/SubLib/IO/Output/SubtitleOutput.cs,
+ src/SubLib/IO/Output/VerboseConsole.cs,
+ src/SubLib/IO/ParsingProperties.cs,
+ src/SubLib/IO/PlainTextParser.cs,
+ src/SubLib/IO/SubtitleFormat.cs,
+ src/SubLib/IO/SubtitleFormatAQTitle.cs,
+ src/SubLib/IO/SubtitleFormatAdobeEncoreDVD.cs,
+ src/SubLib/IO/SubtitleFormatAdvancedSubStationAlpha.cs,
+ src/SubLib/IO/SubtitleFormatDKSSubtitleFormat.cs,
+ src/SubLib/IO/SubtitleFormatKaraokeLyricsLRC.cs,
+ src/SubLib/IO/SubtitleFormatKaraokeLyricsVKT.cs,
+ src/SubLib/IO/SubtitleFormatMPSub.cs,
+ src/SubLib/IO/SubtitleFormatMPlayer.cs,
+ src/SubLib/IO/SubtitleFormatMPlayer2.cs,
+ src/SubLib/IO/SubtitleFormatMacSUB.cs,
+ src/SubLib/IO/SubtitleFormatMicroDVD.cs,
+ src/SubLib/IO/SubtitleFormatPanimator.cs,
+ src/SubLib/IO/SubtitleFormatPhoenixJapanimationSociety.cs,
+ src/SubLib/IO/SubtitleFormatPowerDivX.cs,
+ src/SubLib/IO/SubtitleFormatSofni.cs,
+ src/SubLib/IO/SubtitleFormatSubCreator1x.cs,
+ src/SubLib/IO/SubtitleFormatSubRip.cs,
+ src/SubLib/IO/SubtitleFormatSubStationAlpha.cs,
+ src/SubLib/IO/SubtitleFormatSubViewer1.cs,
+ src/SubLib/IO/SubtitleFormatSubViewer2.cs,
+ src/SubLib/IO/SubtitleFormatViPlaySubtitleFile.cs,
+ src/SubLib/IO/SubtitleFormats/BuiltInSubtitleFormats.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormat.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatAQTitle.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatAdobeEncoreDVD.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatAdvancedSubStationAlpha.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatDKSSubtitleFormat.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatKaraokeLyricsLRC.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatKaraokeLyricsVKT.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatMPSub.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatMPlayer.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatMPlayer2.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatMacSUB.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatMicroDVD.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatPanimator.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatPhoenixJapanimationSociety.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatPowerDivX.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatSofni.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatSubCreator1x.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatSubRip.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatSubStationAlpha.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatSubViewer1.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatSubViewer2.cs,
+ src/SubLib/IO/SubtitleFormats/SubtitleFormatViPlaySubtitleFile.cs,
+ src/SubLib/IO/SubtitleInput.cs, src/SubLib/IO/SubtitleOutput.cs,
+ src/SubLib/IO/SubtitleParser.cs, src/SubLib/IO/VerboseConsole.cs:
+ Major refactoring
+
+2008-09-08 23:46 noup
+
+ * src/SubLib/IO/Input, src/SubLib/IO/Output,
+ src/SubLib/IO/SubtitleFormats: Major refactoring
+
+2008-09-08 23:42 noup
+
+ * src/SubLib/IO, src/SubLib/Persistency: Major refactoring
+
+2008-09-08 23:38 noup
+
+ * src/SubLib/Core/Domain/Enumerations.cs,
+ src/SubLib/Core/Domain/FileProperties.cs,
+ src/SubLib/Core/Domain/Frames.cs,
+ src/SubLib/Core/Domain/Headers.cs,
+ src/SubLib/Core/Domain/IncompleteSubtitle.cs,
+ src/SubLib/Core/Domain/IncompleteSubtitleCollection.cs,
+ src/SubLib/Core/Domain/Style.cs,
+ src/SubLib/Core/Domain/Subtitle.cs,
+ src/SubLib/Core/Domain/SubtitleCollection.cs,
+ src/SubLib/Core/Domain/SubtitleConstants.cs,
+ src/SubLib/Core/Domain/SubtitleHeaders.cs,
+ src/SubLib/Core/Domain/SubtitleProperties.cs,
+ src/SubLib/Core/Domain/SubtitleSearchOptions.cs,
+ src/SubLib/Core/Domain/SubtitleSearchResults.cs,
+ src/SubLib/Core/Domain/SubtitleText.cs,
+ src/SubLib/Core/Domain/SubtitleTypeInfo.cs,
+ src/SubLib/Core/Domain/Subtitles.cs,
+ src/SubLib/Core/Domain/Times.cs, src/SubLib/Core/Enumerations.cs,
+ src/SubLib/Core/FileProperties.cs, src/SubLib/Core/Frames.cs,
+ src/SubLib/Core/Headers.cs,
+ src/SubLib/Core/IncompleteSubtitle.cs,
+ src/SubLib/Core/IncompleteSubtitleCollection.cs,
+ src/SubLib/Core/Style.cs, src/SubLib/Core/Subtitle.cs,
+ src/SubLib/Core/SubtitleCollection.cs,
+ src/SubLib/Core/SubtitleConstants.cs,
+ src/SubLib/Core/SubtitleHeaders.cs,
+ src/SubLib/Core/SubtitleProperties.cs,
+ src/SubLib/Core/SubtitleSearchOptions.cs,
+ src/SubLib/Core/SubtitleSearchResults.cs,
+ src/SubLib/Core/SubtitleText.cs,
+ src/SubLib/Core/SubtitleTypeInfo.cs,
+ src/SubLib/Core/Subtitles.cs, src/SubLib/Core/Times.cs: Major
+ refactoring
+
+2008-09-08 23:34 noup
+
+ * src/SubLib/Core/Domain: Major refactoring
+
+2008-09-08 23:34 noup
+
+ * src/SubLib/Application, src/SubLib/Core: Major refactoring
+
+2008-05-10 19:43 noup
+
+ * AUTHORS, ChangeLog, NEWS, README: Updated for release 0.9.
+
+2008-04-20 00:22 noup
+
+ * src/Makefile.am: Changed sublib_SOURCES to sublib_SCRIPTSOURCES
+ in order for compilation
+ to work with Automake 1.10.
+
+2008-04-17 22:24 noup
+
+ * src/Makefile.am: Fixed to stop complaining about SL prefix.
+
+2008-04-17 22:20 noup
+
+ * data: Added files to ignore list.
+
+2008-04-17 22:14 noup
+
+ * data/Makefile.am, data/sublib.pc.in: Added missing files.
+
+2008-04-14 22:24 noup
+
+ * Makefile.am, configure.in: Do not include docs in default
+ distribution.
+
+2008-04-14 21:55 noup
+
+ * src/SubLib/AssemblyInfo.cs.in: Do not use key anymore.
+
+2008-04-14 21:35 noup
+
+ * Makefile.am, configure.in, src/Makefile.am: Install library and
+ PC file to use with pkg-config. No longer installs to the GAC.
+
+2008-04-14 21:01 noup
+
+ * configure.in, src/Makefile.am, src/SubLib/AssemblyInfo.cs.in:
+ Added support for installing the assembly to the GAC.
+ Use export DOINST="no" to disable this during configure.
+
+2007-10-07 22:25 arklad
+
+ * src/SubLib/Persistency/BuiltInSubtitleFormats.cs: Restored the
+ use of 2000 characters when detecting a subtitle format.
+
+2007-10-07 22:20 arklad
+
+ * src/Executable/Executable.cs,
+ src/SubLib/Application/Enumerations.cs,
+ src/SubLib/Persistency/BuiltInSubtitleFormats.cs,
+ src/SubLib/Persistency/SubtitleFormatAQTitle.cs,
+ src/SubLib/Persistency/SubtitleFormatKaraokeLyricsLRC.cs,
+ src/SubLib/Persistency/SubtitleFormatKaraokeLyricsVKT.cs,
+ src/SubLib/Persistency/SubtitleFormatMacSUB.cs,
+ src/SubLib/Persistency/SubtitleFormatPanimator.cs,
+ src/SubLib/Persistency/SubtitleFormatPhoenixJapanimationSociety.cs,
+ src/SubLib/Persistency/SubtitleFormatSofni.cs,
+ src/SubLib/Persistency/SubtitleFormatSubCreator1x.cs,
+ src/SubLib/Persistency/SubtitleFormatViPlaySubtitleFile.cs: New
+ subtitle formats supported: AQTitle, MacSUB, Sofni, SubCreator
+ 1.x and ViPlay Subtitle File.
+ Access modifiers corrected for some other formats.
+
+2007-10-06 10:32 noup
+
+ * AUTHORS, CREDITS, ChangeLog, NEWS, TODO, configure.in: Updating
+ for release 0.8.
+
+2007-10-04 20:56 arklad
+
+ * src/SubLib/Application/SubtitleFactory.cs,
+ src/SubLib/Persistency/PlainTextParser.cs: Algorithm for
+ importing from plain text files improved.
+
+2007-09-28 22:42 noup
+
+ * src/SubLib/Persistency/PlainTextParser.cs,
+ src/SubLib/Persistency/SubtitleFormatDKSSubtitleFormat.cs,
+ src/SubLib/Persistency/SubtitleFormatPowerDivX.cs: Code cleanup.
+
+2007-09-27 14:30 arklad
+
+ * src/SubLib/Application/SubtitleFactory.cs,
+ src/SubLib/Persistency/PlainTextParser.cs,
+ src/SubLib/Persistency/SubtitleInput.cs: Handles all encodings
+ correctly when importing from a plain text file.
+
+2007-09-21 17:37 noup
+
+ * src/Executable/Executable.cs: Added format to Executable.
+
+2007-09-18 12:00 arklad
+
+ * sublib.mdp: Correct .mdp file for the revision 337.
+
+2007-09-18 11:39 arklad
+
+ * src/Executable/Executable.cs,
+ src/SubLib/Application/Enumerations.cs,
+ src/SubLib/Application/FileProperties.cs,
+ src/SubLib/Application/SubtitleFactory.cs,
+ src/SubLib/Application/SubtitleText.cs,
+ src/SubLib/Persistency/BuiltInSubtitleFormats.cs,
+ src/SubLib/Persistency/PlainTextParser.cs,
+ src/SubLib/Persistency/SubtitleFormatPanimator.cs,
+ src/SubLib/Persistency/SubtitleFormatPhoenixJapanimationSociety.cs,
+ src/SubLib/Persistency/SubtitleInput.cs,
+ src/SubLib/Persistency/SubtitleParser.cs, sublib.mdp: New
+ feature: import text lines from a plain text file, creating a
+ collection of subtitles ready for timing.
+ New formats supported: Panimator and Phoenix Japanimation
+ Society.
+
+2007-09-13 12:41 arklad
+
+ * src/SubLib/Application/Enumerations.cs,
+ src/SubLib/Application/Headers.cs,
+ src/SubLib/Application/SubtitleProperties.cs: Subtitle formats
+ now share headers to make easier loading and saving them.
+
+2007-09-13 12:40 arklad
+
+ * src/SubLib/Persistency/BuiltInSubtitleFormats.cs,
+ src/SubLib/Persistency/ParsingProperties.cs,
+ src/SubLib/Persistency/SubtitleFormatKaraokeLyricsLRC.cs,
+ src/SubLib/Persistency/SubtitleFormatKaraokeLyricsVKT.cs,
+ src/SubLib/Persistency/SubtitleFormatMPSub.cs,
+ src/SubLib/Persistency/SubtitleFormatSubStationAlpha.cs,
+ src/SubLib/Persistency/SubtitleFormatSubViewer1.cs,
+ src/SubLib/Persistency/SubtitleFormatSubViewer2.cs,
+ src/SubLib/Persistency/SubtitleParser.cs: Subtitle formats now
+ share headers to make easier loading and saving them.
+
+2007-09-13 12:37 arklad
+
+ * src/SubLib/Persistency/SubtitleFormatDKSSubtitleFormat.cs,
+ src/SubLib/Persistency/SubtitleFormatPowerDivX.cs: New subtitle
+ formats supported:
+ - DKS Subtitle Format.
+ - Power DivX.
+
+2007-08-20 02:46 noup
+
+ * src/SubLib/Application/SubtitleHeaders.cs,
+ src/SubLib/Persistency/SubtitleParser.cs: Treat the Date header
+ in Karaoke Lyrics VKT as string, as input files aren't garanteed
+ to be in the format assumed by the DateTime parser (and there's
+ no specification of the format available).
+
+2007-08-19 04:04 noup
+
+ * CREDITS: Oops... wrong file. Reverting to previous list of
+ contributors.
+
+2007-08-19 04:03 noup
+
+ * CREDITS: Updated list of contributors.
+
+2007-08-16 19:06 noup
+
+ * src/Executable/Executable.cs,
+ src/SubLib/Application/Enumerations.cs,
+ src/SubLib/Application/SubtitleHeaders.cs,
+ src/SubLib/Persistency/BuiltInSubtitleFormats.cs,
+ src/SubLib/Persistency/SubtitleFormatKaraokeLyricsLRC.cs,
+ src/SubLib/Persistency/SubtitleFormatKaraokeLyricsVKT.cs,
+ src/SubLib/Persistency/SubtitleParser.cs, sublib.mdp: Added
+ support for Karaoke Lyrics LRC and VKT, thanks to Cristina
+ Yenyxe.
+
+2007-08-11 10:49 noup
+
+ * src/SubLib/Application/SubtitleProperties.cs,
+ src/SubLib/Persistency/SubtitleFormat.cs,
+ src/SubLib/Persistency/SubtitleFormatAdobeEncoreDVD.cs,
+ src/SubLib/Persistency/SubtitleFormatMicroDVD.cs,
+ src/SubLib/Persistency/SubtitleFormatSubRip.cs,
+ src/SubLib/Persistency/SubtitleFormatSubStationAlpha.cs,
+ src/SubLib/Persistency/SubtitleParser.cs: Allow to get global
+ properties from the input text before parsing the subtitles.
+ Completed the support for the Adobe Encore DVD format.
+
+2007-08-11 01:10 noup
+
+ * AUTHORS: Updated info.
+
+2007-08-11 01:07 noup
+
+ * CREDITS: Added Cristina Yenyxe to the list of contributors.
+
+2007-08-11 01:05 noup
+
+ * src/Executable/Executable.cs,
+ src/SubLib/Application/Enumerations.cs,
+ src/SubLib/Application/Synchronization.cs,
+ src/SubLib/Persistency/BuiltInSubtitleFormats.cs,
+ src/SubLib/Persistency/SubtitleFormat.cs,
+ src/SubLib/Persistency/SubtitleFormatAdobeEncoreDVD.cs,
+ src/SubLib/Persistency/SubtitleFormatMicroDVD.cs,
+ src/SubLib/Persistency/SubtitleFormatSubRip.cs,
+ src/SubLib/Persistency/SubtitleFormatSubStationAlpha.cs,
+ src/SubLib/Persistency/SubtitleOutput.cs,
+ src/SubLib/Persistency/SubtitleParser.cs, sublib.mdp: Added
+ support for Adobe Encore DVD subtitles, thanks to the help of
+ Cristina Yenyxe.
+ Added support for setting a dynamic subtitle output expression,
+ which is created at runtime based on the subtitle properties.
+
+2007-06-28 01:07 noup
+
+ * AUTHORS, ChangeLog, NEWS, README: Updating for release 0.7.
+
+2007-06-27 01:32 noup
+
+ * src/External/NCharDet, src/External/NCharDet/Big5Statistics.cs,
+ src/External/NCharDet/EUCJPStatistics.cs,
+ src/External/NCharDet/EUCKRStatistics.cs,
+ src/External/NCharDet/EUCTWStatistics.cs,
+ src/External/NCharDet/GB2312Statistics.cs,
+ src/External/NCharDet/nsBIG5Verifier.cs,
+ src/External/NCharDet/nsCP1252Verifier.cs,
+ src/External/NCharDet/nsDetector.cs,
+ src/External/NCharDet/nsEUCJPVerifier.cs,
+ src/External/NCharDet/nsEUCKRVerifier.cs,
+ src/External/NCharDet/nsEUCSampler.cs,
+ src/External/NCharDet/nsEUCStatistics.cs,
+ src/External/NCharDet/nsEUCTWVerifier.cs,
+ src/External/NCharDet/nsGB18030Verifier.cs,
+ src/External/NCharDet/nsGB2312Verifier.cs,
+ src/External/NCharDet/nsHZVerifier.cs,
+ src/External/NCharDet/nsICharsetDetectionObserver.cs,
+ src/External/NCharDet/nsICharsetDetector.cs,
+ src/External/NCharDet/nsISO2022CNVerifier.cs,
+ src/External/NCharDet/nsISO2022JPVerifier.cs,
+ src/External/NCharDet/nsISO2022KRVerifier.cs,
+ src/External/NCharDet/nsPSMDetector.cs,
+ src/External/NCharDet/nsSJISVerifier.cs,
+ src/External/NCharDet/nsUCS2BEVerifier.cs,
+ src/External/NCharDet/nsUCS2LEVerifier.cs,
+ src/External/NCharDet/nsUTF8Verifier.cs,
+ src/External/NCharDet/nsVerifier.cs: Updating with a newer
+ NCharDet version.
+
+2007-06-27 01:31 noup
+
+ * src/External/NCharDet: Updating with a newer NCharDet version.
+
+2007-06-27 01:28 noup
+
+ * src/External/COPYING-MPL: License file for NCharDet.
+
+2007-06-27 01:27 noup
+
+ * src/Executable/Executable.cs: Updated license blocks.
+
+2007-06-27 01:27 noup
+
+ * src/SubLib/Exception/EncodingNotSupportedException.cs,
+ src/SubLib/Exception/UnknownEncodingException.cs,
+ src/SubLib/Exception/UnknownSubtitleFormatException.cs,
+ src/SubLib/Persistency/BuiltInSubtitleFormats.cs,
+ src/SubLib/Persistency/FileInputOutput.cs,
+ src/SubLib/Persistency/ParsingProperties.cs,
+ src/SubLib/Persistency/SubtitleFormat.cs,
+ src/SubLib/Persistency/SubtitleFormatAdvancedSubStationAlpha.cs,
+ src/SubLib/Persistency/SubtitleFormatMPSub.cs,
+ src/SubLib/Persistency/SubtitleFormatMPlayer.cs,
+ src/SubLib/Persistency/SubtitleFormatMPlayer2.cs,
+ src/SubLib/Persistency/SubtitleFormatMicroDVD.cs,
+ src/SubLib/Persistency/SubtitleFormatSubRip.cs,
+ src/SubLib/Persistency/SubtitleFormatSubStationAlpha.cs,
+ src/SubLib/Persistency/SubtitleFormatSubViewer1.cs,
+ src/SubLib/Persistency/SubtitleFormatSubViewer2.cs,
+ src/SubLib/Persistency/SubtitleInput.cs,
+ src/SubLib/Persistency/SubtitleOutput.cs,
+ src/SubLib/Persistency/SubtitleParser.cs,
+ src/SubLib/Persistency/VerboseConsole.cs: Updated license blocks.
+
+2007-06-27 01:27 noup
+
+ * src/SubLib/Application/Enumerations.cs,
+ src/SubLib/Application/FileProperties.cs,
+ src/SubLib/Application/Frames.cs,
+ src/SubLib/Application/IncompleteSubtitle.cs,
+ src/SubLib/Application/IncompleteSubtitleCollection.cs,
+ src/SubLib/Application/MatchEvaluationCounter.cs,
+ src/SubLib/Application/Style.cs,
+ src/SubLib/Application/Subtitle.cs,
+ src/SubLib/Application/SubtitleCollection.cs,
+ src/SubLib/Application/SubtitleConstants.cs,
+ src/SubLib/Application/SubtitleFactory.cs,
+ src/SubLib/Application/SubtitleHeaders.cs,
+ src/SubLib/Application/SubtitleProperties.cs,
+ src/SubLib/Application/SubtitleSaver.cs,
+ src/SubLib/Application/SubtitleSearchOptions.cs,
+ src/SubLib/Application/SubtitleSearchResults.cs,
+ src/SubLib/Application/SubtitleText.cs,
+ src/SubLib/Application/SubtitleTypeInfo.cs,
+ src/SubLib/Application/Subtitles.cs,
+ src/SubLib/Application/Synchronization.cs,
+ src/SubLib/Application/Times.cs,
+ src/SubLib/Application/Translations.cs: Updated license blocks.
+
+2007-06-26 11:45 noup
+
+ * src/SubLib/Application/Enumerations.cs,
+ src/SubLib/Application/Translations.cs,
+ src/SubLib/Exception/EncodingNotSupportedException.cs: Updated
+ API documentation.
+
+2007-06-21 20:25 noup
+
+ * src/SubLib/Persistency/SubtitleOutput.cs: Allow to choose the
+ type of text content to be used for saving (text or translation).
+
+2007-06-21 20:24 noup
+
+ * src/SubLib/Application/Translations.cs, sublib.mdp: New
+ functionality to perform translation operations on subtitles.
+ This includes clearing the translation and importing a
+ translation into existing subtitles.
+
+2007-06-21 20:23 noup
+
+ * src/SubLib/Application/SubtitleSaver.cs: Allow to choose the type
+ of text content to be used for saving (text or translation).
+
+2007-06-21 20:22 noup
+
+ * src/SubLib/Application/Subtitles.cs: Code cleanup.
+
+2007-06-21 20:22 noup
+
+ * src/SubLib/Application/Subtitle.cs: Allow to clear the
+ translation.
+
+2007-06-21 20:21 noup
+
+ * src/Executable/Executable.cs: Updated to the changes in the way
+ subtitles are now saved.
+
+2007-06-14 01:59 noup
+
+ * sublib.mdp: Improved support for translation.
+
+2007-06-14 01:58 noup
+
+ * src/SubLib/Application/SubtitleSearchOptions.cs,
+ src/SubLib/Application/SubtitleSearchResults.cs,
+ src/SubLib/Application/Subtitles.cs: Updated the search methods
+ to cope with the existence of translations, besides the subtitle
+ text.
+ Search options were encapsulated, as well as search results.
+ Fixed some bugs that were visible when doing a backwards search.
+
+2007-06-14 01:55 noup
+
+ * src/SubLib/Application/Enumerations.cs: Updated support for
+ translation.
+
+2007-06-08 18:42 noup
+
+ * src/SubLib/Persistency/SubtitleInput.cs: New method of working
+ with multiple encodings and subtitle format detection. If no
+ encodings are detected, the fallback encoding is used. If
+ multiple encodings are used, the first to work is used. If no
+ encodings work, the errors related to the first tried encoding
+ (the most probable) are reported.
+
+2007-06-08 18:41 noup
+
+ * src/SubLib/Persistency/FileInputOutput.cs: Refactored to get all
+ the detected encodings, so all of them can be tried if the first
+ doesn't work.
+
+2007-06-08 18:39 noup
+
+ * sublib.mdp: Exception to be used when an encoding is not
+ supported by the platform.
+
+2007-06-08 18:39 noup
+
+ * src/SubLib/Exception/EncodingNotSupportedException.cs: Exception
+ to be used when an encoding is not supported by the platform.
+
+2007-06-08 18:38 noup
+
+ * src/SubLib/Application/SubtitleProperties.cs: Code cleanup.
+
+2007-06-08 18:38 noup
+
+ * src/SubLib/Application/SubtitleFactory.cs: Code refactored to use
+ SubtitleInput, which now contains part of the old code.
+
+2007-06-08 18:38 noup
+
+ * src/SubLib/Application/Enumerations.cs: Added enumeration to
+ distinguish from text and translation (and both).
+
+2007-06-06 12:40 noup
+
+ * src/SubLib/Application/Subtitle.cs: Fixed small bug with text
+ being returned instead of translation.
+
+2007-06-05 23:05 noup
+
+ * sublib.mdp: Cleanup.
+
+2007-06-05 23:03 noup
+
+ * src/SubLib/Application/Subtitle.cs: Cleanup.
+
+2007-06-05 23:03 noup
+
+ * src/SubLib/Application/SubtitleText.cs: Revised documentation.
+ Added method to trim the lines when getting them.
+ When replacing empty lines, also apply the replacement if the
+ text is empty.
+
+2007-06-05 23:02 noup
+
+ * src/SubLib/Persistency/SubtitleOutput.cs: Trim lines before
+ saving the text.
+
+2007-06-05 18:30 noup
+
+ * configure.in: Updated with info for the next release.
+
+2007-06-05 18:29 noup
+
+ * src/SubLib/Application/Subtitle.cs: Initial support for
+ translation.
+
+2007-06-05 18:29 noup
+
+ * src/Executable/Executable.cs: Code cleanup.
+
+2007-05-12 01:06 noup
+
+ * ChangeLog: Updated for release 0.6.1
+
+2007-05-12 01:05 noup
+
+ * src/SubLib/Application/FileProperties.cs,
+ src/SubLib/Application/SubtitleSaver.cs,
+ src/SubLib/Persistency/ParsingProperties.cs: Updated SVN
+ properties.
+
+2007-05-12 00:59 noup
+
+ * NEWS, README, configure.in: Updated for release 0.6.1.
+
+2007-05-06 00:59 noup
+
+ * src/SubLib/Application/Enumerations.cs,
+ src/SubLib/Application/FileProperties.cs,
+ src/SubLib/Application/SubtitleSaver.cs,
+ src/SubLib/Persistency/SubtitleOutput.cs, sublib.mdp: Use
+ NewlineType to specify the type of newlines to be used when
+ saving (Macintosh, Unix or Windows).
+
+2007-04-19 10:29 noup
+
+ * NEWS: Updated for latest version.
+
+2007-04-13 17:25 noup
+
+ * AUTHORS, ChangeLog, NEWS, README, configure.in: Updated for the
+ 0.6 release.
+
+2007-04-03 18:24 noup
+
+ * src/SubLib/Application/FileProperties.cs,
+ src/SubLib/Application/SubtitleSaver.cs: Updated the
+ documentation.
+
+2007-04-03 18:08 noup
+
+ * src/Executable/Executable.cs: Updated to reflect latest code
+ changes.
+
+2007-04-03 18:08 noup
+
+ * sublib.mdp: Updated with new files.
+
+2007-04-03 18:07 noup
+
+ * src/SubLib/Application/SubtitleCollection.cs: Added internal
+ method to set the SubtitleProperties for all subtitles.
+
+2007-04-03 18:07 noup
+
+ * src/SubLib/Application/Subtitle.cs: Added internal property to
+ set the SubtitleProperties after a Subtitle object has been
+ created.
+
+2007-04-03 18:05 noup
+
+ * src/SubLib/Application/FileProperties.cs: Class to contain the
+ properties of a file, including its path, encoding, subtitle
+ format, and timing mode.
+
+2007-04-03 18:05 noup
+
+ * src/SubLib/Application/SubtitleFactory.cs: Code cleanup.
+ FileProperties is now used to handle the properties of a file
+ after opening.
+ New and Open methods are more clear now, as some of its
+ derivations were confusing.
+ The Save functionality has moved to SubtitleSaver.
+
+2007-04-03 17:59 noup
+
+ * src/SubLib/Application/SubtitleProperties.cs: Cleanup of
+ properties. SubtitleProperties now only includes properties that
+ are not file-related.
+ FileProperties is used for all file-related properties.
+
+2007-04-03 17:57 noup
+
+ * src/SubLib/Application/Subtitles.cs: Clarified the file saving
+ functionality. The existing functionality in Subtitles was moved
+ to SubtitleSaver. No persistent file-related information is now
+ maintained. FileProperties is used, along with a Subtitles
+ object, to save subtitles.
+
+2007-04-03 17:56 noup
+
+ * src/SubLib/Application/SubtitleSaver.cs: Clarified the file
+ saving functionality. The existing functionality in Subtitles was
+ moved to SubtitleSaver. No persistent file-related information is
+ now maintained. FileProperties is used, along with a Subtitles
+ object, to save subtitles.
+
+2007-04-03 17:49 noup
+
+ * src/SubLib/Persistency/FileInputOutput.cs,
+ src/SubLib/Persistency/SubtitleFormatMPSub.cs,
+ src/SubLib/Persistency/SubtitleFormatSubStationAlpha.cs,
+ src/SubLib/Persistency/SubtitleFormatSubViewer1.cs,
+ src/SubLib/Persistency/SubtitleFormatSubViewer2.cs,
+ src/SubLib/Persistency/SubtitleOutput.cs,
+ src/SubLib/Persistency/SubtitleParser.cs: Fixed copyright dates.
+
+2007-04-03 17:45 noup
+
+ * src/SubLib/Persistency/FileInputOutput.cs: Code cleanup. Fixed
+ the attribution of code pages to some of the encodings. Removed
+ some encodings as they didn't have a related code page.
+
+2007-04-03 17:44 noup
+
+ * src/SubLib/Persistency/SubtitleParser.cs: Cleanup of properties.
+ SubtitleProperties now only includes properties that are not
+ file-related.
+ ParsingProperties is used to store all properties that are
+ gathered when parsing.
+
+2007-04-03 17:42 noup
+
+ * src/SubLib/Persistency/SubtitleOutput.cs: Cleanup of properties.
+ SubtitleProperties now only includes properties that are not
+ file-related.
+ FileProperties is used for all file-related properties.
+
+2007-04-03 17:41 noup
+
+ * src/SubLib/Persistency/SubtitleFormat.cs,
+ src/SubLib/Persistency/SubtitleFormatMPSub.cs,
+ src/SubLib/Persistency/SubtitleFormatSubStationAlpha.cs,
+ src/SubLib/Persistency/SubtitleFormatSubViewer1.cs,
+ src/SubLib/Persistency/SubtitleFormatSubViewer2.cs: Cleanup of
+ properties. SubtitleProperties now only includes properties that
+ are not file-related.
+
+2007-04-03 17:37 noup
+
+ * src/SubLib/Persistency/ParsingProperties.cs: Class that contains
+ properties that result after parsing.
+
+2007-03-05 18:19 noup
+
+ * ChangeLog, NEWS, README, configure.in: Updating for release 0.5.
+
+2007-03-05 18:15 noup
+
+ * src/SubLib/Application/Subtitles.cs,
+ src/SubLib/Application/Synchronization.cs: Updated timestamps.
+
+2007-03-04 19:14 noup
+
+ * .: Updated SVN ignore.
+
+2007-02-25 14:45 noup
+
+ * src/SubLib/Application/Synchronization.cs: Convert from time to
+ frames given the time in seconds.
+
+2007-01-22 02:06 noup
+
+ * src/Executable/Executable.cs,
+ src/SubLib/Application/Subtitles.cs: Added find based on a
+ specific time position.
+
+2006-12-08 03:38 noup
+
+ * ChangeLog, NEWS, README, configure.in: Updated for the 0.4
+ release.
+
+2006-12-08 03:18 noup
+
+ * src/SubLib/Application/SubtitleProperties.cs: Code cleanup.
+
+2006-12-08 03:18 noup
+
+ * src/SubLib/Application/Subtitles.cs: Updated documentation.
+ Set timing mode when using SaveAs, updating it to the timing mode
+ of the new format used.
+ Code cleanup.
+
+2006-12-03 01:56 noup
+
+ * sublib.mdp: Evaluator that enables to count how many matches are
+ made during a string replacement with Regex.
+
+2006-12-03 01:56 noup
+
+ * src/SubLib/Application/MatchEvaluationCounter.cs: Evaluator that
+ enables to count how many matches are made during a string
+ replacement with Regex.
+
+2006-12-03 01:54 noup
+
+ * src/SubLib/Application/Subtitles.cs: Added ReplaceAll
+ functionality.
+
+2006-11-28 22:55 noup
+
+ * src/SubLib/Application/Subtitles.cs: Check if there are no
+ subtitles when doing a Find.
+
+2006-11-26 16:33 noup
+
+ * TODO: Updated the TODO list.
+
+2006-11-26 16:33 noup
+
+ * configure.in: Start using the C#2.0 compiler.
+
+2006-11-26 16:32 noup
+
+ * src/SubLib/Application/SubtitleCollection.cs: Added indexers and
+ a method to check whether an index is valid in a collection.
+
+2006-11-26 16:29 noup
+
+ * src/SubLib/Application/Subtitles.cs: Added methods to Find text
+ in the subtitles. Documentation is still missing.
+ The Find methods use Regex. When using Backwards searching, the
+ Regex must be created with the RegexOptions.RightToLeft option.
+
+2006-11-26 16:27 noup
+
+ * sublib.mdp: Updated compilation flags.
+
+2006-10-30 16:03 noup
+
+ * NEWS: Updated for version 0.3.
+
+2006-10-30 14:08 noup
+
+ * ChangeLog: Updated for release 0.3.
+
+2006-10-30 13:52 noup
+
+ * NEWS, README, configure.in: Updated for release 0.3.
+
+2006-10-30 00:00 noup
+
+ * AUTHORS, CREDITS, TODO: Updated project information files.
+
+2006-10-28 21:26 noup
+
+ * src/SubLib/Application/SubtitleTypeInfo.cs: Added method to check
+ whether a SubtitleTypeInfo contains a specified extension.
+
+2006-10-28 00:51 noup
+
+ * src/SubLib/Application/Subtitles.cs: Updated to reflect changes
+ in FileInputOutput.
+
+2006-10-28 00:51 noup
+
+ * src/SubLib/Application/SubtitleFactory.cs: Added FallbackEncoding
+ property, to set the encoding to fallback to in case
+ autodetection fails.
+ Updated to reflect changes in FileInputOutput.
+
+2006-10-28 00:48 noup
+
+ * src/SubLib/Persistency/FileInputOutput.cs: Fixed bugs that
+ existed by not closing the files, using "finally" statements.
+ Auto-detection throws exception when encoding not detected.
+ Auto-detection with fallback uses the fallback encoding (and
+ possible "detectBOM" boolean) when no encoding is detected.
+ Code cleanup.
+
+2006-10-28 00:46 noup
+
+ * src/SubLib/Exception/UnknownCharEncodingException.cs,
+ src/SubLib/Exception/UnknownEncodingException.cs: Changed
+ UnknownCharEncodingException to UnknownEncodingException
+
+2006-10-28 00:45 noup
+
+ * sublib.mdp: Changed UnknownCharEncodingException to
+ UnknownEncodingException
+
+2006-10-16 00:59 noup
+
+ * src/SubLib/Application/Subtitles.cs: Methods and properties for
+ returning info on the available subtitle types are now static.
+ The AvailableTypes property doesn't sort types from now on. The
+ new AvailableTypesSorted property does sort the types.
+ Added method to return a SubtitleTypeInfo given a SubtitleType.
+
+2006-10-16 00:55 noup
+
+ * src/SubLib/Application/SubtitleTypeInfo.cs: Property to get the
+ preferred extension (the first on the list).
+
+2006-10-04 23:12 noup
+
+ * Makefile.am: Changes for release version 0.2.
+
+2006-10-04 21:50 noup
+
+ * Makefile.am, TODO, src/Makefile.am: Changes for release version
+ 0.2.
+
+2006-10-04 21:01 noup
+
+ * CREDITS, ChangeLog, NEWS, README, configure.in: Changes for
+ release version 0.2.
+
+2006-10-01 21:58 noup
+
+ * src/Makefile.am: Register sublib.dll with noinst so it doesn't
+ get installed (the install target isn't used).
+
+2006-10-01 16:15 noup
+
+ * ChangeLog: Merged with the sublib-dev branch.
+
+2006-10-01 16:14 noup
+
+ * ., ChangeLog: Merged with the sublib-dev branch.
+
+2006-10-01 16:08 noup
+
+ * src/SubLib/Application/Enumerations.cs,
+ src/SubLib/Application/Frames.cs,
+ src/SubLib/Application/SubtitleCollection.cs,
+ src/SubLib/Application/SubtitleCompletion.cs,
+ src/SubLib/Application/SubtitleFactory.cs,
+ src/SubLib/Application/SubtitleHeaders.cs,
+ src/SubLib/Application/SubtitleProperties.cs,
+ src/SubLib/Application/Subtitles.cs,
+ src/SubLib/Application/Times.cs: Merged with the sublib-dev
+ branch.
+
+2006-10-01 16:07 noup
+
+ * src/SubLib/Persistency/BuiltInSubtitleFormats.cs,
+ src/SubLib/Persistency/FileInputOutput.cs,
+ src/SubLib/Persistency/SubtitleFormat.cs,
+ src/SubLib/Persistency/SubtitleFormatAdvancedSubStationAlpha.cs,
+ src/SubLib/Persistency/SubtitleFormatMPSub.cs,
+ src/SubLib/Persistency/SubtitleFormatMPlayer.cs,
+ src/SubLib/Persistency/SubtitleFormatMPlayer2.cs,
+ src/SubLib/Persistency/SubtitleFormatMicroDVD.cs,
+ src/SubLib/Persistency/SubtitleFormatSubRip.cs,
+ src/SubLib/Persistency/SubtitleFormatSubStationAlpha.cs,
+ src/SubLib/Persistency/SubtitleFormatSubViewer1.cs,
+ src/SubLib/Persistency/SubtitleFormatSubViewer2.cs,
+ src/SubLib/Persistency/SubtitleOutput.cs,
+ src/SubLib/Persistency/SubtitleParser.cs: Merged with the
+ sublib-dev branch.
+
+2006-10-01 16:04 noup
+
+ * sublib.mdp, sublib.mds: Merged with the sublib-dev branch.
+
+2006-10-01 15:45 noup
+
+ * src/Executable/Executable.cs: Merged with the sublib-dev branch.
+
+2006-09-01 01:20 noup
+
+ * TODO: No description necessary.
+
+2006-08-30 11:16 noup
+
+ * NEWS: Updated for version 0.1 launch.
+
+2006-08-30 11:03 noup
+
+ * src/SubLib/Application/Frames.cs,
+ src/SubLib/Application/Subtitle.cs,
+ src/SubLib/Application/Times.cs: Merged from sublib-dev.
+
+2006-08-30 10:57 noup
+
+ * src/SubLib/Persistency/VerboseConsole.cs: Merged from sublib-dev.
+
+2006-08-30 10:06 noup
+
+ * configure.in: Updated for version 0.1 launch.
+
+2006-08-30 10:01 noup
+
+ * data/NamespaceSummary.xml: Renamed doc dir to data dir.
+
+2006-08-30 10:00 noup
+
+ * data: Renamed doc dir to data dir.
+
+2006-08-30 09:52 noup
+
+ * build.properties, doc: Renamed doc dir to data dir.
+
+2006-08-30 01:50 noup
+
+ * README: Updated for new install options.
+
+2006-08-30 01:31 noup
+
+ * src/Makefile.am: Updated to create build dir when making the
+ library.
+
+2006-08-30 01:26 noup
+
+ * ChangeLog: Added ChangeLog based on SVN commits.
+
+2006-08-30 01:22 noup
+
+ * ChangeLog, NEWS, TODO: Old ChangeLog contents are now in NEWS.
+
+2006-08-30 01:19 noup
+
+ * NEWS: Removed to exchange with data from ChangeLog.
+
+2006-08-29 19:23 noup
+
+ * ., src, src/Makefile.am, src/SubLib: Cleaned-up makefiles.
+
+2006-08-01 10:39 noup
+
+ * nant.build: Updated not to show warnings when members aren't
+ documented.
+
+2006-07-20 21:19 noup
+
+ * src/SubLib/Application/SubtitleCollection.cs: Improved validation
+ of some methods' arguments.
+ Added methods to create and insert new subtitles at a specified
+ position, or after or before existing subtitles, based on them.
+
+2006-07-20 21:16 noup
+
+ * src/SubLib/Persistency/FileInputOutput.cs: Fixed some warnings.
+
+2006-07-15 03:11 noup
+
+ * src/SubLib/Application/SubtitleConstants.cs: Updated with default
+ values for properties.
+
+2006-07-14 22:47 noup
+
+ * src/SubLib/Application/SubtitleConstants.cs, sublib.mdp: Added
+ constants to a set of subtitle parameters.
+
+2006-07-08 18:56 noup
+
+ * src/SubLib/Application/SubtitleFactory.cs,
+ src/SubLib/Exception/UnknownCharEncodingException.cs,
+ src/SubLib/Exception/UnknownSubtitleFormatException.cs: Added
+ documentation.
+
+2006-07-07 17:41 noup
+
+ * src/SubLib/Application/Subtitles.cs: Current and Original frame
+ rates are now only seteable internally, so they cannot be changed
+ without using Subtitles.ChangeFrameRate or
+ Subtitles.ChangeOriginalFrameRate.
+ Added documentation.
+
+2006-07-07 17:40 noup
+
+ * src/SubLib/Application/SubtitleCompletion.cs,
+ src/SubLib/Application/SubtitleProperties.cs: Current and
+ Original frame rates are now only seteable internally, so they
+ cannot be changed without using Subtitles.ChangeFrameRate or
+ Subtitles.ChangeOriginalFrameRate.
+
+2006-07-05 00:49 noup
+
+ * build.properties, nant.build: Updated for new naming conventions
+ for the library.
+
+2006-07-05 00:49 noup
+
+ * sublib.mdp: Removed the ParsedSubtitles class. Parsed values are
+ now returned using "out".
+
+2006-07-05 00:48 noup
+
+ * src/SubLib/Application/ParsedSubtitles.cs: Removed the
+ ParsedSubtitles class. Parsed values are now returned using
+ "out".
+
+2006-07-05 00:39 noup
+
+ * src/SubLib/Application/SubtitleFactory.cs: Removed the
+ ParsedSubtitles class. Parsed values are now returned using
+ "out".
+
+2006-07-05 00:20 noup
+
+ * src/SubLib/Application/SubtitleCompletion.cs: Code cleanup.
+
+2006-07-04 23:28 noup
+
+ * src/SubLib/Application/SubtitleCollection.cs: Code cleanup.
+ Added some useful methods.
+
+2006-07-04 23:22 noup
+
+ * src/SubLib/Application/Subtitle.cs: Code cleanup.
+
+2006-07-04 22:57 noup
+
+ * src/SubLib/Application/IncompleteSubtitle.cs,
+ src/SubLib/Application/IncompleteSubtitleCollection.cs: Code
+ cleanup.
+
+2006-07-04 22:55 noup
+
+ * src/SubLib/Application/SubtitleProperties.cs: Corrected the
+ documentation.
+
+2006-07-04 22:43 noup
+
+ * src/SubLib/Application/SubtitleText.cs: Added some useful
+ methods.
+
+2006-07-04 22:41 noup
+
+ * src/SubLib/Application/SubtitleTypeInfo.cs: Written
+ documentation.
+
+2006-07-04 22:38 noup
+
+ * src/SubLib/Application/Synchronization.cs: Written documentation.
+
+2006-07-04 22:38 noup
+
+ * src/SubLib/Application/Times.cs: Written documentation.
+ Removed unused isSubtitleValid properties.
+ Code cleanup.
+
+2006-07-04 22:37 noup
+
+ * src/SubLib/Application/Frames.cs: Written documentation.
+ Removed unused isSubtitleValid properties.
+ Code cleanup.
+
+2006-07-04 22:35 noup
+
+ * src/SubLib/Persistency/SubtitleParser.cs: Removed the
+ ParsedSubtitles class. Parsed values are now returned using
+ "out".
+
+2006-06-27 21:50 noup
+
+ * src/SubLib/Application/IncompleteSubtitle.cs,
+ src/SubLib/Application/IncompleteSubtitleCollection.cs,
+ src/SubLib/Application/Style.cs,
+ src/SubLib/Application/Subtitle.cs,
+ src/SubLib/Application/SubtitleCollection.cs,
+ src/SubLib/Application/SubtitleProperties.cs,
+ src/SubLib/Application/SubtitleText.cs: Added and revised
+ documentation.
+
+2006-06-27 19:44 noup
+
+ * sublib.mdp: ISubtitleCollection's need wasn't very logical.
+ SubtitleCollection and IncompleteSubtitleCollection are now 2
+ completely separate classes.
+
+2006-06-27 19:43 noup
+
+ * src/SubLib/Application/SubtitleProperties.cs: Added
+ documentation.
+
+2006-06-27 19:43 noup
+
+ * src/SubLib/Application/ISubtitleCollection.cs,
+ src/SubLib/Application/IncompleteSubtitleCollection.cs,
+ src/SubLib/Application/SubtitleCollection.cs:
+ ISubtitleCollection's need wasn't very logical.
+ SubtitleCollection and IncompleteSubtitleCollection are now 2
+ completely separate classes.
+
+2006-06-27 19:41 noup
+
+ * nant.build: Add properties to clearly mark unwritten
+ documentation.
+
+2006-06-27 00:44 noup
+
+ * .: Added files to cvsignore.
+
+2006-06-27 00:38 noup
+
+ * src/SubLib/Application/Enumerations.cs,
+ src/SubLib/Application/Style.cs,
+ src/SubLib/Application/SubtitleText.cs: Written code comments.
+
+2006-06-26 19:44 noup
+
+ * sublib.mdp, sublib.mds: Imported the project into Monodevelop.
+
+2006-06-26 00:24 noup
+
+ * INSTALL, Makefile.am, NEWS, autogen.sh, configure.in,
+ src/External/NCharDet/AssemblyInfo.cs, src/Makefile.am,
+ src/SubLib/AssemblyInfo.cs.in: Added support for autotools, to
+ build the library without nant.
+
+2006-06-18 18:10 noup
+
+ * src/SubLib/Application/SubtitleText.cs: Also trim text around
+ line breaks when specified.
+
+2006-06-18 17:59 noup
+
+ * src/SubLib/Application/SubtitleText.cs: Fixed bug with last
+ change, trimming is not functioning properly.
+
+2006-06-18 17:40 noup
+
+ * src/SubLib/Application/SubtitleText.cs,
+ src/SubLib/Persistency/SubtitleFormatMicroDVD.cs,
+ src/SubLib/Persistency/SubtitleFormatSubRip.cs,
+ src/SubLib/Persistency/SubtitleParser.cs: Possibility to select
+ if text should be trimmed when set in a subtitle.
+ Text is trimmed by default when opening subtitles, but not
+ trimmed by default when using Set with only 1 argument (the
+ text).
+
+2006-03-17 01:44 noup
+
+ * build.properties, doc, doc/NamespaceSummary.xml, nant.build:
+ Initial support for documentation, created with ndoc.
+
+2006-03-05 02:42 noup
+
+ * src/SubLib/Application/SubtitleFactory.cs: Updated verbose
+ messages for opening.
+
+2006-03-05 01:35 noup
+
+ * src/SubLib/Application/SubtitleFactory.cs: Created method for
+ setting properties, used after open and save as.
+
+2006-03-05 01:35 noup
+
+ * src/SubLib/Application/Subtitles.cs: Created method for setting
+ properties, used after open and save as.
+
+2006-03-05 01:34 noup
+
+ * src/SubLib/Application/SubtitleCompletion.cs,
+ src/SubLib/Application/SubtitleProperties.cs: Removed
+ OriginalTimingMode property.
+
+2006-03-05 01:19 noup
+
+ * src/SubLib/Persistency/SubtitleParser.cs: moved the set up of
+ properties after parsing to subtitle factory
+
+2006-03-05 01:11 noup
+
+ * TODO: Added TODO list.
+
+2006-03-05 01:10 noup
+
+ * src/SubLib/Persistency/SubtitleFormatMicroDVD.cs: Only create
+ styleExpression once.
+
+2006-03-05 01:10 noup
+
+ * src/SubLib/Persistency/SubtitleFormatSubRip.cs: Corrected bug
+ with not reading the last character when parsing input.
+ Only create styleExpression once.
+
+2006-03-04 18:47 noup
+
+ * src/Executable/Executable.cs: Updated for verbose mechanism
+ change.
+
+2006-03-04 18:46 noup
+
+ * src/SubLib/Exception/UnknownCharEncodingException.cs: Renaming
+ exception related to unknown character coding.
+
+2006-03-04 18:46 noup
+
+ * src/SubLib/Exception/UnknownFileEncodingException.cs: Renaming
+ exception related to unknown character coding.
+
+2006-03-04 18:42 noup
+
+ * src/SubLib/Persistency/VerboseConsole.cs: Verbose console output
+ methods.
+
+2006-03-04 18:42 noup
+
+ * src/SubLib/Persistency/FileInputOutput.cs: Moved verbose
+ mechanism to a separate class, to be used internally in the whole
+ namespace.
+ Allow to write files with a specified encoding.
+
+2006-03-04 18:39 noup
+
+ * src/SubLib/Persistency/SubtitleFormatSubRip.cs: Conform to the
+ new specification: set subtitle name and extensions.
+
+2006-03-04 18:39 noup
+
+ * src/SubLib/Persistency/SubtitleFormatMicroDVD.cs: Conform to the
+ new specification: set subtitle name and extensions.
+
+2006-03-04 18:38 noup
+
+ * src/SubLib/Persistency/SubtitleFormat.cs: Also store subtitle
+ format's name and extensions.
+ Oblige to be extended to be used
+ Code cleanup
+
+2006-03-04 18:35 noup
+
+ * src/SubLib/Persistency/BuiltInSubtitleFormats.cs: Code cleanup.
+
+2006-03-04 18:22 noup
+
+ * src/SubLib/Application/SubtitleTypeInfo.cs: Class that stores
+ information about a subtitle type.
+
+2006-03-04 18:18 noup
+
+ * src/SubLib/Application/Subtitles.cs: Allow to save using a
+ specified encoding
+ Store the new file encoding when saving as
+ Updated verbosity mechanism
+
+2006-03-04 18:17 noup
+
+ * src/SubLib/Application/SubtitleProperties.cs: added file encoding
+ property
+ code cleanup
+
+2006-03-04 18:15 noup
+
+ * src/SubLib/Application/SubtitleFactory.cs: set encoding name in
+ properties when opening a file
+ updated verbosity mechanism
+ code cleanup
+
+2006-03-01 03:26 noup
+
+ * src/SubLib/Persistency/SubtitleFormat.cs: Code cleanup.
+
+2006-03-01 03:17 noup
+
+ * src/SubLib/Persistency/SubtitleFormatMicroDVD.cs: Code cleanup.
+
+2006-03-01 03:14 noup
+
+ * src/SubLib/Persistency/SubtitleFormatSubRip.cs: Simplified
+ regular expressions.
+ FormatExpression is more rigid (to better detect the format)
+ InputExpression breaks subtitles when it finds a blank line
+ OutputExpression uses the system's newline (\r\n on windows, \n
+ on unix)
+
+2006-03-01 00:52 noup
+
+ * src/Executable/Executable.cs: Updated Save to SaveAs.
+
+2006-03-01 00:51 noup
+
+ * src/SubLib/Persistency/BuiltInSubtitleFormats.cs: Heuristics
+ change, now a format can be considered "the best" which makes the
+ detection return immediately.
+ Only the first 2000 characters of the text are used in the
+ detection.
+ Regular expressions are not compiled anymore, since it didn't
+ really make much sense in this context (and has the problem about
+ memory not being freed)
+
+2006-03-01 00:49 noup
+
+ * src/SubLib/Persistency/SubtitleFormatMicroDVD.cs: More precise
+ support for subtitle format detection (more rigid).
+
+2006-02-28 22:58 noup
+
+ * src/SubLib/Application/Subtitles.cs: Save returns true if it
+ could save (using CanSave), false otherwise.
+
+2006-02-28 02:04 noup
+
+ * src/SubLib/Application/Subtitles.cs: Operations for saving,
+ saving as and knowing if a file can be saved without additional
+ parameters.
+
+2006-02-28 02:03 noup
+
+ * src/SubLib/Application/SubtitleFactory.cs,
+ src/SubLib/Application/SubtitleProperties.cs: Store the
+ SubtitleType after reading a file.
+
+2006-02-27 16:51 noup
+
+ * ChangeLog: Updating for release 0.0.5
+
+2006-02-27 16:27 noup
+
+ * src/SubLib/Application/IncompleteSubtitle.cs,
+ src/SubLib/Application/ParsedSubtitles.cs,
+ src/SubLib/Application/Style.cs,
+ src/SubLib/Application/SubtitleProperties.cs,
+ src/SubLib/Application/Subtitles.cs,
+ src/SubLib/Persistency/SubtitleParser.cs: Code cleanup.
+
+2006-02-27 16:24 noup
+
+ * src/SubLib/Application/SubtitleCollection.cs: Fixed bug when
+ adding an element to the beginning of the collection.
+
+2006-02-24 03:51 noup
+
+ * .cvsignore: deleting remaining CVS files.
+
+2006-02-22 12:22 noup
+
+ * src/Executable/Executable.cs,
+ src/SubLib/Application/Enumerations.cs,
+ src/SubLib/Application/Frames.cs,
+ src/SubLib/Application/ISubtitleCollection.cs,
+ src/SubLib/Application/IncompleteSubtitle.cs,
+ src/SubLib/Application/IncompleteSubtitleCollection.cs,
+ src/SubLib/Application/ParsedSubtitles.cs,
+ src/SubLib/Application/Style.cs,
+ src/SubLib/Application/Subtitle.cs,
+ src/SubLib/Application/SubtitleCollection.cs,
+ src/SubLib/Application/SubtitleCompletion.cs,
+ src/SubLib/Application/SubtitleFactory.cs,
+ src/SubLib/Application/SubtitleProperties.cs,
+ src/SubLib/Application/SubtitleText.cs,
+ src/SubLib/Application/Subtitles.cs,
+ src/SubLib/Application/Synchronization.cs,
+ src/SubLib/Application/Times.cs, src/SubLib/Domain,
+ src/SubLib/Exception,
+ src/SubLib/Exception/UnknownFileEncodingException.cs,
+ src/SubLib/Exception/UnknownSubtitleFormatException.cs,
+ src/SubLib/Persistency/BuiltInSubtitleFormats.cs,
+ src/SubLib/Persistency/Exception,
+ src/SubLib/Persistency/FileInputOutput.cs,
+ src/SubLib/Persistency/SubtitleFormat.cs,
+ src/SubLib/Persistency/SubtitleFormatMicroDVD.cs,
+ src/SubLib/Persistency/SubtitleFormatSubRip.cs,
+ src/SubLib/Persistency/SubtitleOutput.cs,
+ src/SubLib/Persistency/SubtitleParser.cs: Namespace change: only
+ 1 namespace now - SubLib.
+ Domain layer removed, since it wasn't making much sense. Its
+ files were moved to "Application", which now contains all the
+ public classes.
+ Exception classes were also moved to the SubLib's source root.
+
+2006-02-22 12:16 noup
+
+ * nant.build: Added rebuild target.
+
+2006-02-19 03:30 noup
+
+ * src/SubLib/Application/SubtitleFactory.cs: Stop being verbose by
+ default.
+
+2006-02-15 01:13 noup
+
+ * src/SubLib/Persistency/FileInputOutput.cs: Fixed bug with
+ detecting the character encoding. Now tries 1252 if both
+ detection and the default encoding failed.
+
+2006-02-15 00:18 noup
+
+ * src/SubLib/Application/SubtitleFactory.cs,
+ src/SubLib/Domain/Frames.cs, src/SubLib/Domain/SubtitleText.cs,
+ src/SubLib/Domain/Times.cs: Removed Domain.Exception namespace.
+
+2006-02-15 00:01 noup
+
+ * src/SubLib/Domain/Exception, src/SubLib/Domain/Frames.cs,
+ src/SubLib/Domain/Times.cs: Stop throwing exceptions when times
+ and frames aren't valid (use IsValid to validate)
+
+2006-02-14 23:28 noup
+
+ * src/SubLib/Domain/ISubtitleCollection.cs,
+ src/SubLib/Domain/IncompleteSubtitleCollection.cs,
+ src/SubLib/Domain/SubtitleCollection.cs: subtitle numbers now
+ start at 0
+
+2006-02-14 23:20 noup
+
+ * src/SubLib/Domain/Exception/InvalidSubtitleTextException.cs,
+ src/SubLib/Domain/Frames.cs, src/SubLib/Domain/Subtitle.cs,
+ src/SubLib/Domain/SubtitleText.cs, src/SubLib/Domain/Times.cs:
+ Code cleanup.
+ Restructured constructors.
+ Stoped throwing exception when values aren't initialized (values
+ are always initialized from now on).
+
+2006-02-06 06:06 noup
+
+ * src/SubLib/Application/SubtitleCompletion.cs,
+ src/SubLib/Domain/Enumerations.cs,
+ src/SubLib/Domain/SubtitleProperties.cs,
+ src/SubLib/Persistency/SubtitleFormat.cs,
+ src/SubLib/Persistency/SubtitleFormatMicroDVD.cs,
+ src/SubLib/Persistency/SubtitleFormatSubRip.cs,
+ src/SubLib/Persistency/SubtitleParser.cs: Removed the Unknown
+ field of the TimingMode enumeration, so it can also be used
+ externaly.
+
+2006-02-05 05:18 noup
+
+ * src/SubLib/Application/SubtitleFactory.cs,
+ src/SubLib/Domain/Frames.cs,
+ src/SubLib/Domain/SubtitleProperties.cs,
+ src/SubLib/Domain/Times.cs: Added a better path handling: allow
+ to store them in SubtitleProperties and create new subtitles in
+ SubtitleFactory
+ Timings' duration can now be set
+
+2006-01-30 03:58 noup
+
+ * src/SubLib/Application/SubtitleFactory.cs,
+ src/SubLib/Domain/SubtitleProperties.cs,
+ src/SubLib/Domain/Subtitles.cs: Subtitles constructor is now
+ protected, so the class can be inherited
+ SubtitleProperties readjusted, some properties were not necessary
+ SubtitleFactory can now create new initial blank subtitles
+
+2006-01-29 01:54 noup
+
+ * ChangeLog, src/SubLib/Domain/Subtitle.cs,
+ src/SubLib/Domain/SubtitleText.cs,
+ src/SubLib/Persistency/BuiltInSubtitleFormats.cs,
+ src/SubLib/Persistency/SubtitleFormat.cs,
+ src/SubLib/Persistency/SubtitleFormatMicroDVD.cs,
+ src/SubLib/Persistency/SubtitleFormatSubRip.cs,
+ src/SubLib/Persistency/SubtitleParser.cs: MicroDVD: now detects
+ style tags anywhere inside subtitles' text
+ SubRip: fixed bug related to style parsing
+ Parsing engine optimized
+ Subtitle regular expressions are case-insensitive by default
+ Subtitles are now trimmed
+ Added Get() to SubtitleText, which retrieves subtitles separated
+ by the newline character
+
+2005-10-29 14:32 noup
+
+ * ChangeLog: Updating for version 0.0.3.
+
+2005-10-29 13:59 noup
+
+ * ChangeLog: Updating for version 0.0.3.
+
+2005-10-29 13:50 noup
+
+ * AUTHORS, COPYING, ChangeLog, nant.build,
+ src/Executable/Executable.cs,
+ src/External/NCharDet/AssemblyInfo.cs,
+ src/External/NCharDet/Big5Statistics.cs,
+ src/External/NCharDet/EUCJPStatistics.cs,
+ src/External/NCharDet/EUCKRStatistics.cs,
+ src/External/NCharDet/EUCTWStatistics.cs,
+ src/External/NCharDet/GB2312Statistics.cs,
+ src/External/NCharDet/nsBIG5Verifier.cs,
+ src/External/NCharDet/nsCP1252Verifier.cs,
+ src/External/NCharDet/nsDetector.cs,
+ src/External/NCharDet/nsEUCJPVerifier.cs,
+ src/External/NCharDet/nsEUCKRVerifier.cs,
+ src/External/NCharDet/nsEUCSampler.cs,
+ src/External/NCharDet/nsEUCStatistics.cs,
+ src/External/NCharDet/nsEUCTWVerifier.cs,
+ src/External/NCharDet/nsGB18030Verifier.cs,
+ src/External/NCharDet/nsGB2312Verifier.cs,
+ src/External/NCharDet/nsHZVerifier.cs,
+ src/External/NCharDet/nsICharsetDetectionObserver.cs,
+ src/External/NCharDet/nsICharsetDetector.cs,
+ src/External/NCharDet/nsISO2022CNVerifier.cs,
+ src/External/NCharDet/nsISO2022JPVerifier.cs,
+ src/External/NCharDet/nsISO2022KRVerifier.cs,
+ src/External/NCharDet/nsPSMDetector.cs,
+ src/External/NCharDet/nsSJISVerifier.cs,
+ src/External/NCharDet/nsUCS2BEVerifier.cs,
+ src/External/NCharDet/nsUCS2LEVerifier.cs,
+ src/External/NCharDet/nsUTF8Verifier.cs,
+ src/External/NCharDet/nsVerifier.cs,
+ src/SubLib/Application/SubtitleCompletion.cs,
+ src/SubLib/Application/SubtitleFactory.cs,
+ src/SubLib/Application/Synchronization.cs,
+ src/SubLib/Domain/ISubtitleCollection.cs,
+ src/SubLib/Domain/IncompleteSubtitle.cs,
+ src/SubLib/Domain/IncompleteSubtitleCollection.cs,
+ src/SubLib/Domain/ParsedSubtitles.cs, src/SubLib/Domain/Style.cs,
+ src/SubLib/Domain/Subtitle.cs,
+ src/SubLib/Domain/SubtitleCollection.cs,
+ src/SubLib/Domain/SubtitleProperties.cs,
+ src/SubLib/Persistency/BuiltInSubtitleFormats.cs,
+ src/SubLib/Persistency/Exception/UnknownFileEncodingException.cs,
+ src/SubLib/Persistency/Exception/UnknownSubtitleFormatException.cs,
+ src/SubLib/Persistency/FileInputOutput.cs,
+ src/SubLib/Persistency/SubtitleFormat.cs,
+ src/SubLib/Persistency/SubtitleFormatMicroDVD.cs,
+ src/SubLib/Persistency/SubtitleFormatSubRip.cs,
+ src/SubLib/Persistency/SubtitleOutput.cs,
+ src/SubLib/Persistency/SubtitleParser.cs: changed ascii/binary
+ property
+
+2005-10-29 13:44 noup
+
+ * README, build.properties, nant.build,
+ src/Executable/Executable.cs, src/SubLib/Domain/Frames.cs,
+ src/SubLib/Domain/Subtitle.cs, src/SubLib/Domain/Times.cs,
+ src/SubLib/Persistency/SubtitleOutput.cs,
+ src/SubLib/Persistency/SubtitleParser.cs: Frames and Times aren't
+ hidden in the subtitle class anymore. Their methods and
+ properties are now public, but they have to be constructed by
+ Subtitle (internal constructor). They also include 2 types of
+ access: common and precise. Precise is for internal use and the
+ other is public.
+ Updated the nant build file with targets to make releases.
+ Updated the README file with the current program usage.
+
+2005-10-26 17:50 noup
+
+ * ChangeLog, src/Executable/Executable.cs,
+ src/SubLib/Application/SubtitleCompletion.cs,
+ src/SubLib/Application/SubtitleFactory.cs,
+ src/SubLib/Application/Subtitles.cs,
+ src/SubLib/Application/Synchronization.cs,
+ src/SubLib/Domain/Exception,
+ src/SubLib/Domain/Exception/InvalidEndFrameException.cs,
+ src/SubLib/Domain/Exception/InvalidEndTimeException.cs,
+ src/SubLib/Domain/Exception/InvalidStartFrameException.cs,
+ src/SubLib/Domain/Exception/InvalidStartTimeException.cs,
+ src/SubLib/Domain/Exception/InvalidSubtitleTextException.cs,
+ src/SubLib/Domain/Frames.cs,
+ src/SubLib/Domain/ISubtitleCollection.cs,
+ src/SubLib/Domain/IncompleteSubtitleCollection.cs,
+ src/SubLib/Domain/Style.cs, src/SubLib/Domain/Subtitle.cs,
+ src/SubLib/Domain/SubtitleCollection.cs,
+ src/SubLib/Domain/SubtitleProperties.cs,
+ src/SubLib/Domain/SubtitleText.cs,
+ src/SubLib/Domain/Subtitles.cs, src/SubLib/Domain/Times.cs,
+ src/SubLib/Persistency/FileInputOutput.cs,
+ src/SubLib/Persistency/SubtitleFormatSubRip.cs,
+ src/SubLib/Persistency/SubtitleOutput.cs,
+ src/SubLib/Persistency/SubtitleParser.cs,
+ src/SubLib/Persistency/SubtitleReader.cs,
+ src/SubLib/Persistency/SubtitleWriter.cs: - architecture
+ restructured, now features a rich domain model which connects
+ both to the application and persistency layers.
+ - subtitle domain now includes frames and times as classes, and
+ automatically updates the times when changing frames and
+ vice-versa; one has to use the internally-available properties of
+ frames and times to set their values without changing the others
+ - parsing engine rewrite, parsed bits are returned instead of
+ passing a subtitle class to each parsing method
+ - improved the parsing engine's efficiency, using a string
+ builder instead of common strings.
+ - added an optional argument to the executable, to change the
+ input fps
+
+2005-10-22 23:19 noup
+
+ * README: minor change for README
+
+2005-10-22 23:17 noup
+
+ * AUTHORS, ChangeLog: updated for version 0.0.2
+
+2005-10-22 23:05 noup
+
+ * README, src/Executable/Executable.cs,
+ src/SubLib/Application/SubtitleCompletion.cs,
+ src/SubLib/Application/SubtitleFactory.cs,
+ src/SubLib/Application/Subtitles.cs,
+ src/SubLib/Application/Synchronization.cs,
+ src/SubLib/Domain/Enumerations.cs, src/SubLib/Domain/Subtitle.cs,
+ src/SubLib/Domain/SubtitleCollection.cs,
+ src/SubLib/Domain/SubtitleProperties.cs,
+ src/SubLib/Persistency/BuiltInSubtitleFormats.cs,
+ src/SubLib/Persistency/SubtitleFormat.cs,
+ src/SubLib/Persistency/SubtitleOutput.cs,
+ src/SubLib/Persistency/SubtitleParser.cs,
+ src/SubLib/Persistency/SubtitleReader.cs: Added synchronization
+ utilities. The correct place for the related methods is still to
+ be decided, but the added top-level features are changing the fps
+ and the input fps.
+ Internaly, there is also the function of updating the time from
+ frames and vice-versa (SetTimeFromFrames and SetFramesFromTime).
+ Written a README file.
+
+2005-10-15 18:12 noup
+
+ * ., .cvsignore, src/Executable/Executable.cs,
+ src/SubLib/Application/SubtitleCompletion.cs,
+ src/SubLib/Application/SubtitleFactory.cs,
+ src/SubLib/Application/Subtitles.cs,
+ src/SubLib/Application/Synchronization.cs,
+ src/SubLib/Application/TimeUtilities.cs,
+ src/SubLib/Domain/SubtitleProperties.cs,
+ src/SubLib/Persistency/FileInputOutput.cs,
+ src/SubLib/Persistency/SubtitleFormat.cs,
+ src/SubLib/Persistency/SubtitleFormatMicroDVD.cs,
+ src/SubLib/Persistency/SubtitleFormatSubRip.cs,
+ src/SubLib/Persistency/SubtitleReader.cs: SubtitleFormat isn't
+ static anymore
+ SubtitleFormat accepts many properties, which can be specified
+ before opening a subtitle
+ Added a way to enable verbose prints during the opening of a
+ file.
+
+2005-10-14 10:50 noup
+
+ * src/SubLib/Domain/SubtitleProperties.cs: *** empty log message
+ ***
+
+2005-10-11 23:34 noup
+
+ * nant.build: cleaned-up build file.
+
+2005-10-09 01:09 noup
+
+ * src/SubLib/Domain/Subtitle.cs,
+ src/SubLib/Persistency/SubtitleFormat.cs,
+ src/SubLib/Persistency/SubtitleFormatSubRip.cs,
+ src/SubLib/Persistency/SubtitleOutput.cs,
+ src/SubLib/Persistency/SubtitleParser.cs: improved parsing
+ engine:
+ - added a PostProcess function, to deal with particularities that
+ may arise from some subtitle formats (as of now, SubRip, in what
+ comes to finding and deleting tags inside the subtitle text)
+ - improved parsing of SubRip subtitles
+ - refactored the conversions between subtitle text strings and
+ arraylists (with the subtitle lines), which is now in the
+ subtitle text (SetText and GetText functions)
+
+2005-09-24 17:11 noup
+
+ * ChangeLog: Added Changelog for version 0.0.1.
+
+2005-09-24 01:28 noup
+
+ * src/Executable/Executable.cs,
+ src/SubLib/Application/SubtitleCompletion.cs,
+ src/SubLib/Application/SubtitleFactory.cs,
+ src/SubLib/Application/Subtitles.cs,
+ src/SubLib/Application/TimeUtilities.cs,
+ src/SubLib/Domain/ISubtitleCollection.cs,
+ src/SubLib/Domain/Subtitle.cs,
+ src/SubLib/Domain/SubtitleCollection.cs,
+ src/SubLib/Persistency/SubtitleParser.cs: Added timing completion
+ upon parsing.
+ Subtitle class doesn't create a subtitle with zero time by
+ default any more. Instead, it creates a subtitle with invalid
+ time.
+ Improved executable to detect operating system and show usage
+ instructions.
+
+2005-08-20 18:28 noup
+
+ * src/Executable/Executable.cs,
+ src/SubLib/Application/SubtitleCompletion.cs,
+ src/SubLib/Application/SubtitleFactory.cs,
+ src/SubLib/Application/Subtitles.cs,
+ src/SubLib/Domain/MovieSubtitles.cs,
+ src/SubLib/Domain/ParsedSubtitles.cs,
+ src/SubLib/Domain/SubtitleCollection.cs,
+ src/SubLib/Domain/SubtitleProperties.cs,
+ src/SubLib/Persistency/SubtitleFormatMicroDVD.cs,
+ src/SubLib/Persistency/SubtitleFormatSubRip.cs,
+ src/SubLib/Persistency/SubtitleOutput.cs,
+ src/SubLib/Persistency/SubtitleParser.cs,
+ src/SubLib/Persistency/SubtitleReader.cs,
+ src/SubLib/Persistency/SubtitleWriter.cs: Started building the
+ application layer, which structure was rearranged.
+ Corrected some minor bugs related to SubRip and MicroDVD
+ subtitles parsing.
+ Now uses a SubtitleFactory class to create Subtitles from text
+ files. The incomplete subtitles are optionaly retrieved from the
+ SubtitleFactory after reading the subtitles.
+
+2005-08-14 00:08 noup
+
+ * src/Executable/Executable.cs,
+ src/External/NCharDet/nsDetector.cs,
+ src/SubLib/Persistency/FileInputOutput.cs,
+ src/SubLib/Persistency/SubtitleParser.cs: Fixed bug with the
+ encoding detection, wasn't detecting correctly because some parts
+ of the buffer were only used in ascii detection, and not in the
+ global one.
+ Added a statistics feature to the testing executable.
+
+2005-08-11 11:34 noup
+
+ * src/Executable/Executable.cs, src/SubLib/Domain/Style.cs,
+ src/SubLib/Domain/Subtitle.cs,
+ src/SubLib/Persistency/BuiltInSubtitleFormats.cs,
+ src/SubLib/Persistency/FileInputOutput.cs,
+ src/SubLib/Persistency/SubtitleFormat.cs,
+ src/SubLib/Persistency/SubtitleFormatMicroDVD.cs,
+ src/SubLib/Persistency/SubtitleFormatSubRip.cs,
+ src/SubLib/Persistency/SubtitleOutput.cs,
+ src/SubLib/Persistency/SubtitleParser.cs,
+ src/SubLib/Persistency/SubtitleReader.cs: Added complete support
+ for SubRip subtitles.
+ The parsing engine now better supports parsing of time-based
+ subtitles.
+ Persistency structure changed, each subtitle type has a specific
+ related file now.
+
+2005-07-23 21:20 noup
+
+ * ChangeLog, build.properties, nant.build,
+ src/Executable/Executable.cs, src/External,
+ src/External/NCharDet, src/External/NCharDet/AssemblyInfo.cs,
+ src/External/NCharDet/Big5Statistics.cs,
+ src/External/NCharDet/EUCJPStatistics.cs,
+ src/External/NCharDet/EUCKRStatistics.cs,
+ src/External/NCharDet/EUCTWStatistics.cs,
+ src/External/NCharDet/GB2312Statistics.cs,
+ src/External/NCharDet/nsBIG5Verifier.cs,
+ src/External/NCharDet/nsCP1252Verifier.cs,
+ src/External/NCharDet/nsDetector.cs,
+ src/External/NCharDet/nsEUCJPVerifier.cs,
+ src/External/NCharDet/nsEUCKRVerifier.cs,
+ src/External/NCharDet/nsEUCSampler.cs,
+ src/External/NCharDet/nsEUCStatistics.cs,
+ src/External/NCharDet/nsEUCTWVerifier.cs,
+ src/External/NCharDet/nsGB18030Verifier.cs,
+ src/External/NCharDet/nsGB2312Verifier.cs,
+ src/External/NCharDet/nsHZVerifier.cs,
+ src/External/NCharDet/nsICharsetDetectionObserver.cs,
+ src/External/NCharDet/nsICharsetDetector.cs,
+ src/External/NCharDet/nsISO2022CNVerifier.cs,
+ src/External/NCharDet/nsISO2022JPVerifier.cs,
+ src/External/NCharDet/nsISO2022KRVerifier.cs,
+ src/External/NCharDet/nsPSMDetector.cs,
+ src/External/NCharDet/nsSJISVerifier.cs,
+ src/External/NCharDet/nsUCS2BEVerifier.cs,
+ src/External/NCharDet/nsUCS2LEVerifier.cs,
+ src/External/NCharDet/nsUTF8Verifier.cs,
+ src/External/NCharDet/nsVerifier.cs,
+ src/SubLib/Application/Subtitles.cs,
+ src/SubLib/Domain/ISubtitleCollection.cs,
+ src/SubLib/Domain/IncompleteSubtitle.cs,
+ src/SubLib/Domain/IncompleteSubtitleCollection.cs,
+ src/SubLib/Domain/MovieSubtitles.cs, src/SubLib/Domain/Style.cs,
+ src/SubLib/Domain/Subtitle.cs,
+ src/SubLib/Domain/SubtitleCollection.cs,
+ src/SubLib/Persistency/BuiltInSubtitleFormats.cs,
+ src/SubLib/Persistency/Exception/InvalidPathException.cs,
+ src/SubLib/Persistency/Exception/UnknownFileEncodingException.cs,
+ src/SubLib/Persistency/Exception/UnknownSubtitleFormatException.cs,
+ src/SubLib/Persistency/FileInputOutput.cs,
+ src/SubLib/Persistency/SubtitleFormat.cs,
+ src/SubLib/Persistency/SubtitleOutput.cs,
+ src/SubLib/Persistency/SubtitleParser.cs,
+ src/SubLib/Persistency/SubtitleReader.cs,
+ src/SubLib/Persistency/SubtitleWriter.cs: Added support for
+ automatic file encoding detection.
+ Added support for automatic subtitle format detection.
+ Parser now supports strict and relaxed expressions, and also the
+ option to create a list of the detected invalid subtitles (which
+ couldn't be fixed).
+ Complete support for reading and writing subtitles.
+ Added support for MicroDVD subtitles.
+
+2005-07-16 17:51 noup
+
+ * src/Executable/Executable.cs,
+ src/SubLib/Application/Subtitles.cs,
+ src/SubLib/Domain/MovieSubtitles.cs,
+ src/SubLib/Domain/Subtitle.cs,
+ src/SubLib/Domain/SubtitleCollection.cs,
+ src/SubLib/Domain/SubtitleProperties.cs,
+ src/SubLib/Persistency/BuiltInSubtitleFormats.cs,
+ src/SubLib/Persistency/FileInputOutput.cs,
+ src/SubLib/Persistency/SubtitleFormat.cs,
+ src/SubLib/Persistency/SubtitleParser.cs,
+ src/SubLib/Persistency/SubtitleReader.cs: Standardized getters
+ and setters.
+ New (very) experimental parsing engine.
+ Use the current locale the default encoding detector doesn't
+ succeed.
+
+2005-07-14 04:47 noup
+
+ * src/Executable/Executable.cs: Adding a basic testing executable.
+
+2005-05-31 22:33 noup
+
+ * ., .project, AUTHORS, COPYING, ChangeLog, build.properties,
+ nant.build, src, src/Executable, src/Executable/Executable.cs,
+ src/SubLib, src/SubLib/Application,
+ src/SubLib/Application/Subtitles.cs, src/SubLib/Domain,
+ src/SubLib/Domain/MovieSubtitles.cs,
+ src/SubLib/Domain/Subtitle.cs,
+ src/SubLib/Domain/SubtitleCollection.cs,
+ src/SubLib/Domain/SubtitleProperties.cs, src/SubLib/Persistency,
+ src/SubLib/Persistency/BuiltInSubtitleFormats.cs,
+ src/SubLib/Persistency/Exception,
+ src/SubLib/Persistency/Exception/InvalidPathException.cs,
+ src/SubLib/Persistency/FileInputOutput.cs,
+ src/SubLib/Persistency/SubtitleFormat.cs,
+ src/SubLib/Persistency/SubtitleParser.cs,
+ src/SubLib/Persistency/SubtitleReader.cs: Initial CVS commit.
+
diff --git a/src/SubLib/Core/Domain/Enumerations.cs b/src/SubLib/Core/Domain/Enumerations.cs
new file mode 100644
index 0000000..c04f68c
--- /dev/null
+++ b/src/SubLib/Core/Domain/Enumerations.cs
@@ -0,0 +1,147 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+namespace SubLib.Core.Domain {
+
+/// <summary>
+/// Represents a timing mode, which can be frame or time based.
+/// </summary>
+public enum TimingMode {
+ /// <summary>Time based timing mode.</summary>
+ Times,
+
+ /// <summary>Frame based timing mode.</summary>
+ Frames
+};
+
+/// <summary>
+/// Represents a supported subtitle file type.
+/// </summary>
+public enum SubtitleType {
+ /// <summary>Unknown subtitle type.</summary>
+ Unknown ,
+
+ /// <summary>Micro DVD subtitle type.</summary>
+ MicroDVD,
+
+ /// <summary>SubRip subtitle type.</summary>
+ SubRip,
+
+ /// <summary>Sub Station Alpha subtitle type.</summary>
+ SubStationAlpha,
+
+ /// <summary>Advanced Sub Station Alpha subtitle type.</summary>
+ AdvancedSubStationAlpha,
+
+ /// <summary>MPlayer subtitle type.</summary>
+ MPlayer,
+
+ /// <summary>MPlayer2 subtitle type.</summary>
+ MPlayer2,
+
+ /// <summary>MPSub subtitle type.</summary>
+ MPSub,
+
+ /// <summary>SubViewer 1.0 subtitle type.</summary>
+ SubViewer1,
+
+ /// <summary>SubViewer 2.0 subtitle type.</summary>
+ SubViewer2,
+
+ /// <summary>AQ Title subtitle type.</summary>
+ AQTitle,
+
+ /// <summary>MacSUB subtitle type.</summary>
+ MacSUB,
+
+ /// <summary>Phoenix Japanimation Society subtitle type.</summary>
+ PhoenixJapanimationSociety,
+
+ /// <summary>Panimator subtitle type.</summary>
+ Panimator,
+
+ /// <summary>Sofni subtitle type.</summary>
+ Sofni,
+
+ /// <summary>SubCreator 1.x subtitle type.</summary>
+ SubCreator1x,
+
+ /// <summary>ViPlay Subtitle File subtitle type.</summary>
+ ViPlaySubtitleFile,
+
+ /// <summary>DKS Subtitle Format subtitle type.</summary>
+ DKSSubtitleFormat,
+
+ /// <summary>Power DivX subtitle type.</summary>
+ PowerDivX,
+
+ /// <summary>Karaoke Lyrics LRC subtitle type.</summary>
+ KaraokeLyricsVKT,
+
+ /// <summary>Karaoke Lyrics LRC subtitle type.</summary>
+ KaraokeLyricsLRC,
+
+ /// <summary>Adobe Encore DVD subtitle type.</summary>
+ AdobeEncoreDVD
+};
+
+/// <summary>
+/// Represents a type of newline.
+/// </summary>
+public enum NewlineType {
+ /// <summary>Unknown newline type.</summary>
+ Unknown ,
+
+ /// <summary>Unix newline type.</summary>
+ Unix,
+
+ /// <summary>Windows newline type.</summary>
+ Windows,
+
+ /// <summary>Macintosh newline type.</summary>
+ Macintosh,
+};
+
+/// <summary>
+/// Represents the type of text content.
+/// </summary>
+public enum SubtitleTextType {
+ /// <summary>The text.</summary>
+ Text,
+
+ /// <summary>The translation.</summary>
+ Translation
+};
+
+
+/// <summary>
+/// Represents the timing mode used by a subtitle format.
+/// </summary>
+internal enum SubtitleMode {
+ /// <summary>Time based timing mode.</summary>
+ Times,
+
+ /// <summary>Frame based timing mode.</summary>
+ Frames,
+
+ /// <summary>Time and Frame based timing mode.</summary>
+ Both
+};
+
+}
diff --git a/src/SubLib/Core/Domain/FileProperties.cs b/src/SubLib/Core/Domain/FileProperties.cs
new file mode 100644
index 0000000..89ebc75
--- /dev/null
+++ b/src/SubLib/Core/Domain/FileProperties.cs
@@ -0,0 +1,129 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System;
+using System.Text;
+
+namespace SubLib.Core.Domain {
+
+/// <summary>Represents the properties of a file.</summary>
+/// <remarks>This includes all that's necessary to work with files, in relation to <see cref="Subtitles" />.</remarks>
+public class FileProperties {
+ /* Used for reading and writing */
+ private string path = String.Empty; //The path of the file
+ private Encoding encoding = null; //The character coding of the file
+ private SubtitleType subtitleType = SubtitleType.Unknown; //The subtitle type of the file
+ private TimingMode timingMode = TimingMode.Times; //The timing mode used in the file (some subtitle types support both)
+
+ /* Used for writing only */
+ private NewlineType newlineType = NewlineType.Unknown;
+
+ /// <summary>Creates a new instance of the <see cref="FileProperties" /> class.</summary>
+ /// <remarks>All properties are initialized to defaults.</remarks>
+ public FileProperties () {
+ }
+
+ /// <summary>Creates a new instance of the <see cref="FileProperties" /> class, given its properties.</summary>
+ /// <param name="path">The file's path.</param>
+ /// <param name="encoding">The file's character coding.</param>
+ /// <param name="subtitleType">The file's subtitle type.</param>
+ /// <param name="timingMode">The file's timing mode. This is more useful for the subtitle types that support both the time and frame modes.</param>
+ /// <param name="newlineType">The file's newline type.</param>
+ public FileProperties (string path, Encoding encoding, SubtitleType subtitleType, TimingMode timingMode, NewlineType newlineType) {
+ this.path = path;
+ this.encoding = encoding;
+ this.subtitleType = subtitleType;
+ this.timingMode = timingMode;
+ this.newlineType = newlineType;
+ }
+
+ /// <summary>Creates a new instance of the <see cref="FileProperties" /> class, given its properties.</summary>
+ /// <param name="path">The file's path.</param>
+ /// <param name="encoding">The file's character coding.</param>
+ /// <param name="subtitleType">The file's subtitle type.</param>
+ /// <param name="timingMode">The file's timing mode. This is more useful for the subtitle types that support both the time and frame modes.</param>
+ public FileProperties (string path, Encoding encoding, SubtitleType subtitleType, TimingMode timingMode)
+ : this(path, encoding, subtitleType, timingMode, NewlineType.Unknown) {
+ }
+
+ /// <summary>Creates a new instance of the <see cref="FileProperties" /> class, given its properties.</summary>
+ /// <param name="path">The file's path.</param>
+ /// <param name="encoding">The file's character coding.</param>
+ /// <param name="timingMode">The file's timing mode. This is more useful for the subtitle types that support both the time and frame modes.</param>
+ public FileProperties(string path, Encoding encoding, TimingMode timingMode)
+ : this(path, encoding, SubtitleType.Unknown, timingMode) {
+ }
+
+ /// <summary>Creates a new instance of the <see cref="FileProperties" /> class, given the file's path.</summary>
+ /// <param name="path">The file's path.</param>
+ public FileProperties (string path) : this(path, null, SubtitleType.Unknown, TimingMode.Times) {
+ }
+
+ /// <summary>The file's path.</summary>
+ public string Path {
+ get { return path; }
+ set { path = System.IO.Path.GetFullPath(value); }
+ }
+
+ /// <summary>The file's filename.</summary>
+ /// <remarks>See <see cref="System.IO.Path.GetFileName" /> for more information.</remarks>
+ public string Filename {
+ get { return System.IO.Path.GetFileName(path); }
+ }
+
+ /// <summary>The file's directory.</summary>
+ /// <remarks>See <see cref="System.IO.Path.GetDirectoryName" /> for more information.</remarks>
+ public string Directory {
+ get { return System.IO.Path.GetDirectoryName(path); }
+ }
+
+ /// <summary>Whether the path is rooted.</summary>
+ /// <remarks>See <see cref="System.IO.Path.IsPathRooted" /> for more information.</remarks>
+ public bool IsPathRooted {
+ get { return System.IO.Path.IsPathRooted(path); }
+ }
+
+ /// <summary>The character coding used in the file.</summary>
+ public Encoding Encoding {
+ get { return encoding; }
+ set { encoding = value; }
+ }
+
+ /// <summary>The timing mode used in the file.</summary>
+ /// <remarks>This is more useful for the subtitle types that support both the time and frame modes.</remarks>
+ public TimingMode TimingMode {
+ get { return timingMode; }
+ set { timingMode = value; }
+ }
+
+ /// <summary>The type of the subtitles.</summary>
+ public SubtitleType SubtitleType {
+ get { return subtitleType; }
+ set { subtitleType = value; }
+ }
+
+ /// <summary>The type of newline used in the file.</summary>
+ public NewlineType NewlineType {
+ get { return newlineType; }
+ set { newlineType = value; }
+ }
+
+}
+
+}
\ No newline at end of file
diff --git a/src/SubLib/Core/Domain/Frames.cs b/src/SubLib/Core/Domain/Frames.cs
new file mode 100644
index 0000000..e2778bf
--- /dev/null
+++ b/src/SubLib/Core/Domain/Frames.cs
@@ -0,0 +1,116 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System;
+
+namespace SubLib.Core.Domain {
+
+/// <summary>Represents the frames of a subtitle.</summary>
+/// <remarks><see cref="Frames" /> and <see cref="Times" /> always exist for any <see cref="Subtitle" />.
+/// This class is automatically constructed when constructing a <see cref="Subtitle" />.</remarks>
+public class Frames {
+ private double start = 0;
+ private double end = 0;
+ private Subtitle subtitle = null;
+
+
+ /// <summary>The start frame.</summary>
+ /// <remarks>Upon setting the start frame, the start time (<see cref="Times.Start">Times.Start</see>) is also updated based on
+ /// the <see cref="SubtitleProperties.CurrentFrameRate" />.</remarks>
+ public int Start {
+ get { return (int)Math.Round(PreciseStart); }
+ set {
+ PreciseStart = value;
+ subtitle.UpdateStartTimeFromFrames();
+ }
+ }
+
+ /// <summary>The end frame.</summary>
+ /// <remarks>Upon setting the end frame, the end time (<see cref="Times.End">Times.End</see>) is also updated based on
+ /// the <see cref="SubtitleProperties.CurrentFrameRate" />.</remarks>
+ public int End {
+ get { return (int)Math.Round(PreciseEnd); }
+ set {
+ PreciseEnd = value;
+ subtitle.UpdateEndTimeFromFrames();
+ }
+ }
+
+ /// <summary>The duration, in frames.</summary>
+ /// <remarks>Setting the duration maintains the start frame and changes the end frame.
+ /// Upon setting the duration, the end time (<see cref="Times.End">Times.End</see>) is also updated based on
+ /// the <see cref="SubtitleProperties.CurrentFrameRate" />.</remarks>
+ public int Duration {
+ get { return End - Start; }
+ set { End = Start + value; }
+ }
+
+ /// <summary>Shifts the subtitle with a specified amount of frames.</summary>
+ /// <param name="frames">The number of frames to shift the subtitle with, which can be positive or negative.</param>
+ public void Shift (int frames) {
+ PreciseStart += frames;
+ PreciseEnd += frames;
+ subtitle.UpdateTimesFromFrames();
+ }
+
+
+ public override string ToString() {
+ return Start + "->" + End;
+ }
+
+ /* Internal members */
+
+ internal Frames (Subtitle subtitle) {
+ this.subtitle = subtitle;
+ }
+
+ internal Frames (Subtitle subtitle, int start, int end) {
+ this.start = start;
+ this.end = end;
+ this.subtitle = subtitle;
+ }
+
+ /// <remarks>Doesn't update times.</remarks>
+ internal double PreciseStart {
+ get { return start; }
+ set { start = value; }
+ }
+
+ /// <remarks>Doesn't update times.</remarks>
+ internal double PreciseEnd {
+ get { return end; }
+ set { end = value; }
+ }
+
+ /// <remarks>Doesn't update times.</remarks>
+ internal double PreciseDuration {
+ get { return end - start; }
+ set { end = start + value; }
+ }
+
+ internal void Scale (double factor, int baseFrame) {
+ PreciseStart = baseFrame + ((PreciseStart - baseFrame) * factor);
+ PreciseEnd = baseFrame + ((PreciseEnd - baseFrame) * factor);
+
+ subtitle.UpdateTimesFromFrames();
+ }
+
+}
+
+}
diff --git a/src/SubLib/Core/Domain/Headers.cs b/src/SubLib/Core/Domain/Headers.cs
new file mode 100644
index 0000000..cfd4827
--- /dev/null
+++ b/src/SubLib/Core/Domain/Headers.cs
@@ -0,0 +1,326 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2006-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System;
+using System.IO;
+using System.Text;
+
+namespace SubLib.Core.Domain {
+
+/// <summary>Represents the headers of the supported subtitle formats.</summary>
+public class Headers {
+
+ private string title = String.Empty;
+ private string author = String.Empty;
+ private string movieAuthor = String.Empty;
+ private string artist = String.Empty;
+ private string album = String.Empty;
+ private string videoSource = String.Empty;
+ private string subtitlesSource = String.Empty;
+ private string program = String.Empty;
+ private string version = String.Empty;
+ private string comment = String.Empty;
+ private string fontColor = "&HFFFFFF";
+ private string fontStyle = "bd";
+ private string fontName = "Tahoma";
+ private string fileProperties = String.Empty;
+ private string mediaType = "VIDEO";
+ private string originalScript = "<unknown>";
+ private string originalTranslation = String.Empty;
+ private string originalEditing = String.Empty;
+ private string originalTiming = String.Empty;
+ private string originalScriptChecking = String.Empty;
+ private string scriptUpdatedBy = String.Empty;
+ private string collisions = String.Empty;
+ private string timer = String.Empty;
+ private string frameRate = String.Empty;
+ private string date = DateTime.Today.ToString("yyyy-MM-dd");
+ private int playResX = 0;
+ private int playResY = 0;
+ private int playDepth = 0;
+ private int fontSize = 24;
+ private int delay = 0;
+ private int cdTrack = 0;
+
+ /// <summary>The movie's title.</summary>
+ public string Title {
+ get { return title; }
+ set { title = value; }
+ }
+
+ /// <summary>The subtitles' author.</summary>
+ public string Author {
+ get { return author; }
+ set { author = value; }
+ }
+
+ /// <summary>The movie's author.</summary>
+ public string MovieAuthor {
+ get { return movieAuthor; }
+ set { movieAuthor = value; }
+ }
+
+ /// <summary>The subtitles' artist.</summary>
+ public string Artist {
+ get { return artist; }
+ set { artist = value; }
+ }
+
+ /// <summary>The subtitles' album.</summary>
+ public string Album {
+ get { return album; }
+ set { album = value; }
+ }
+
+ /// <summary>The video' source.</summary>
+ public string VideoSource {
+ get { return videoSource; }
+ set { videoSource = value; }
+ }
+
+ /// <summary>The subtitles' source.</summary>
+ public string SubtitlesSource {
+ get { return subtitlesSource; }
+ set { subtitlesSource = value; }
+ }
+
+ /// <summary>The name of the subtitles' program.</summary>
+ public string Program {
+ get { return program; }
+ set { program = value; }
+ }
+
+ /// <summary>The version of the subtitles.</summary>
+ public string Version {
+ get { return version; }
+ set { version = value; }
+ }
+
+ /// <summary>A comment or note on the subtitles.</summary>
+ public string Comment {
+ get { return comment; }
+ set { comment = value; }
+ }
+
+ /// <summary>The subtitles' font color.</summary>
+ public string FontColor {
+ get { return fontColor; }
+ set { fontColor = value; }
+ }
+
+ /// <summary>The subtitles' font style.</summary>
+ public string FontStyle {
+ get { return fontStyle; }
+ set { fontStyle = value; }
+ }
+
+ /// <summary>The subtitles' font name.</summary>
+ public string FontName {
+ get { return fontName; }
+ set { fontName = value; }
+ }
+
+ /// <summary>The File properties, in the format 'size,md5'.</summary>
+ public string FileProperties {
+ get { return fileProperties; }
+ set { fileProperties = value; }
+ }
+
+ /// <summary>The Media Type of the subtitles, which can be 'VIDEO' or 'AUDIO'.</summary>
+ /// <remarks>This property is only set if the value is 'VIDEO' or 'AUDIO'. It's case insensitive.</remarks>
+ public string MediaType {
+ get { return mediaType; }
+ set {
+ string type = value.ToUpper();
+ if (type.Equals("VIDEO") || type.Equals("AUDIO"))
+ mediaType = type;
+ }
+ }
+
+ /// <summary>The Original Script of the subtitles.</summary>
+ public string OriginalScript {
+ get { return originalScript; }
+ set { originalScript = value; }
+ }
+
+ /// <summary>The Original Translation of the subtitles.</summary>
+ public string OriginalTranslation {
+ get { return originalTranslation; }
+ set { originalTranslation = value; }
+ }
+
+ /// <summary>The Original Editing of the subtitles.</summary>
+ public string OriginalEditing {
+ get { return originalEditing; }
+ set { originalEditing = value; }
+ }
+
+ /// <summary>The Original Timing of the subtitles.</summary>
+ public string OriginalTiming {
+ get { return originalTiming; }
+ set { originalTiming = value; }
+ }
+
+ /// <summary>The Original Script Checking of the subtitles.</summary>
+ public string OriginalScriptChecking {
+ get { return originalScriptChecking; }
+ set { originalScriptChecking = value; }
+ }
+
+ /// <summary>The Script Updated By of the subtitles.</summary>
+ public string ScriptUpdatedBy {
+ get { return scriptUpdatedBy; }
+ set { scriptUpdatedBy = value; }
+ }
+
+ /// <summary>The Collisions of the subtitles.</summary>
+ public string Collisions {
+ get { return collisions; }
+ set { collisions = value; }
+ }
+
+ /// <summary>The Timer of the subtitles.</summary>
+ public string Timer {
+ get { return timer; }
+ set { timer = value; }
+ }
+
+ /// <summary>The movie's frame rate.</summary>
+ public string FrameRate {
+ get { return frameRate; }
+ set { frameRate = value; }
+ }
+
+ /// <summary>The subtitles' date.</summary>
+ public string Date {
+ get { return date; }
+ set { date = value; }
+ }
+
+ /// <summary>The PlayResX of the subtitles.</summary>
+ public int PlayResX {
+ get { return playResX; }
+ set { playResX = value; }
+ }
+
+ /// <summary>The PlayResX of the subtitles as text.</summary>
+ public string PlayResXAsText {
+ get { return playResX.ToString(); }
+ set {
+ try {
+ playResX = Convert.ToInt32(value);
+ }
+ catch (Exception) {
+ }
+ }
+ }
+
+ /// <summary>The PlayResY of the subtitles.</summary>
+ public int PlayResY {
+ get { return playResY; }
+ set { playResY = value; }
+ }
+
+ /// <summary>The PlayResY of the subtitles as text.</summary>
+ public string PlayResYAsText {
+ get { return playResY.ToString(); }
+ set {
+ try {
+ playResY = Convert.ToInt32(value);
+ }
+ catch (Exception) {
+ }
+ }
+ }
+
+ /// <summary>The PlayDepth of the subtitles.</summary>
+ public int PlayDepth {
+ get { return playDepth; }
+ set { playDepth = value; }
+ }
+
+ /// <summary>The PlayResY of the subtitles as text.</summary>
+ public string PlayDepthAsText {
+ get { return playDepth.ToString(); }
+ set {
+ try {
+ playDepth = Convert.ToInt32(value);
+ }
+ catch (Exception) {
+ }
+ }
+ }
+
+ /// <summary>The subtitles' font size.</summary>
+ public int FontSize {
+ get { return fontSize; }
+ set { fontSize = value; }
+ }
+
+ /// <summary>The subtitles' font size as text.</summary>
+ public string FontSizeAsText {
+ get { return fontSize.ToString(); }
+ set {
+ try {
+ fontSize = Convert.ToInt32(value);
+ }
+ catch (Exception) {
+ }
+ }
+ }
+
+ /// <summary>The delay of the subtitles.</summary>
+ public int Delay {
+ get { return delay; }
+ set { delay = value; }
+ }
+
+ /// <summary>The delay of the subtitles as text.</summary>
+ public string DelayAsText {
+ get { return delay.ToString(); }
+ set {
+ try {
+ delay = Convert.ToInt32(value);
+ }
+ catch (Exception) {
+ }
+ }
+ }
+
+ /// <summary>The CD track of the subtitles.</summary>
+ public int CDTrack {
+ get { return cdTrack; }
+ set { cdTrack = value; }
+ }
+
+ /// <summary>The CD track of the subtitles as text.</summary>
+ public string CDTrackAsText {
+ get { return cdTrack.ToString(); }
+ set {
+ try {
+ cdTrack = Convert.ToInt32(value);
+ }
+ catch (Exception) {
+ }
+ }
+ }
+
+}
+
+}
\ No newline at end of file
diff --git a/src/SubLib/Core/Domain/IncompleteSubtitle.cs b/src/SubLib/Core/Domain/IncompleteSubtitle.cs
new file mode 100644
index 0000000..e66a010
--- /dev/null
+++ b/src/SubLib/Core/Domain/IncompleteSubtitle.cs
@@ -0,0 +1,58 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System;
+
+namespace SubLib.Core.Domain {
+
+/// <summary>Represents an incomplete subtitle.</summary>
+/// <remarks>An incomplete subtitle is characterized by its incomplete text and
+/// the valid subtitle that precedes it.</remarks>
+public class IncompleteSubtitle {
+ private int previous = 0;
+ private string text = String.Empty;
+
+ /// <summary>Initializes a new instance of the <see cref="IncompleteSubtitle" /> class,
+ /// given the index of its preceding valid subtitle and the incomplete text.</summary>
+ /// <param name="previous">The index of the preceding valid subtitle.</param>
+ /// <param name="text">The subtitle's incomplete text.</param>
+ public IncompleteSubtitle (int previous, string text) {
+ this.previous = previous;
+ this.text = text;
+ }
+
+ /// <summary>The index of the preceding valid subtitle.</summary>
+ public int Previous {
+ get { return previous; }
+ set { previous = value; }
+ }
+
+ /// <summary>The incomplete subtitle's text.</summary>
+ public string Text {
+ get { return text; }
+ set { text = value; }
+ }
+
+ public override string ToString(){
+ return "* After " + previous + ": " + text + "\n";
+ }
+
+}
+
+}
diff --git a/src/SubLib/Core/Domain/IncompleteSubtitleCollection.cs b/src/SubLib/Core/Domain/IncompleteSubtitleCollection.cs
new file mode 100644
index 0000000..b9f5895
--- /dev/null
+++ b/src/SubLib/Core/Domain/IncompleteSubtitleCollection.cs
@@ -0,0 +1,70 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System.Collections;
+
+namespace SubLib.Core.Domain {
+
+/// <summary>A container that represents a collection of incomplete subtitles.</summary>
+public class IncompleteSubtitleCollection {
+ private ArrayList subtitles = new ArrayList();
+
+
+ /// <summary>The number of subtitles in the collection.</summary>
+ public int Count {
+ get { return subtitles.Count; }
+ }
+
+ /// <summary>Returns an enumerator that can iterate through the collection.</summary>
+ /// <returns>An <see cref="IEnumerator" /> for the entire <see cref="IncompleteSubtitleCollection" />.</returns>
+ public IEnumerator GetEnumerator () {
+ return subtitles.GetEnumerator();
+ }
+
+ /// <summary>Returns the subtitle at the specified index.</summary>
+ /// <param name="index">The zero-based subtitle's index.</param>
+ /// <returns>The subtitle at the specified index.</returns>
+ public IncompleteSubtitle Get (int index){
+ return (IncompleteSubtitle)subtitles[index];
+ }
+
+ /// <summary>Adds an incomplete subtitle to the end of the collection.</summary>
+ /// <param name="subtitle">The subtitle to add.</param>
+ public void Add (IncompleteSubtitle subtitle){
+ subtitles.Add(subtitle);
+ }
+
+ /// <summary>Adds an incomplete subtitle to the collection, inserting it at the specified index.</summary>
+ /// <param name="subtitle">The subtitle to add.</param>
+ /// <param name="index">The zero-based index at which the subtitle should be inserted.</param>
+ public void Add (IncompleteSubtitle subtitle, int index){
+ subtitles.Insert(index, subtitle);
+ }
+
+ public override string ToString(){
+ string result = "\t* SUBTITLE LIST *\n";
+ foreach(IncompleteSubtitle subtitle in subtitles){
+ result += subtitle.ToString();
+ }
+ return result;
+ }
+
+}
+
+}
diff --git a/src/SubLib/Core/Domain/Style.cs b/src/SubLib/Core/Domain/Style.cs
new file mode 100644
index 0000000..9e61f4c
--- /dev/null
+++ b/src/SubLib/Core/Domain/Style.cs
@@ -0,0 +1,82 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System;
+using System.Collections;
+
+namespace SubLib.Core.Domain {
+
+/// <summary>Represents a text style, including Bold, Italic and Underline.</summary>
+public class Style {
+ private bool bold = false;
+ private bool italic = false;
+ private bool underline = false;
+
+ /// <summary>Initializes a new instance of the <see cref="SubLib.Style" /> class.</summary>
+ public Style () {}
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Style" /> class, given the
+ /// specified style values.</summary>
+ /// <param name="bold">Whether the text is bold.</param>
+ /// <param name="italic">Whether the text is italic.</param>
+ /// <param name="underline">Whether the text is underlined.</param>
+ public Style (bool bold, bool italic, bool underline) {
+ this.bold = bold;
+ this.italic = italic;
+ this.underline = underline;
+ }
+
+ /// <summary>Whether the style is bold.</summary>
+ public bool Bold {
+ get { return bold; }
+ set { bold = value; }
+ }
+
+ /// <summary>Whether the style is italic.</summary>
+ public bool Italic {
+ get { return italic; }
+ set { italic = value; }
+ }
+
+ /// <summary>Whether the style is underlined.</summary>
+ public bool Underline {
+ get { return underline; }
+ set { underline = value; }
+ }
+
+ /// <summary>Whether any of the style values is enabled.</summary>
+ public bool Enabled {
+ get { return Bold || Italic || Underline; }
+ }
+
+ public override string ToString() {
+ string result = String.Empty;
+ if (Bold)
+ result += " bold";
+ if (Italic)
+ result += " italic";
+ if (Underline)
+ result += " underline";
+ return result;
+ }
+
+}
+
+}
diff --git a/src/SubLib/Core/Domain/Subtitle.cs b/src/SubLib/Core/Domain/Subtitle.cs
new file mode 100644
index 0000000..a7ba2ea
--- /dev/null
+++ b/src/SubLib/Core/Domain/Subtitle.cs
@@ -0,0 +1,181 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2009 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Timing;
+using System;
+
+namespace SubLib.Core.Domain {
+
+/// <summary>Represents a subtitle, including its time settings, text and text style.</summary>
+public class Subtitle {
+ private SubtitleProperties properties = null;
+ private Times times = null;
+ private Frames frames = null;
+ private SubtitleText text = null;
+ private SubtitleText translation = null;
+ private Style style = null;
+
+ /// <summary>Initializes a new instance of the <see cref="Subtitle" /> class, given the
+ /// global subtitles' properties and the subtitle's text and style.</summary>
+ /// <param name="properties">The subtitles' properties.</param>
+ /// <param name="text">The subtitle's text.</param>
+ /// <param name="style">The subtitle's style.</param>
+ public Subtitle (SubtitleProperties properties, SubtitleText text, Style style) {
+ this.properties = properties;
+ this.text = text;
+ this.style = style;
+
+ times = new Times(this);
+ frames = new Frames(this);
+ }
+
+ /// <summary>Initializes a new instance of the <see cref="Subtitle" /> class, given the
+ /// global subtitles' properties and its start and end times.</summary>
+ /// <param name="properties">The subtitles' properties.</param>
+ /// <param name="startTime">The subtitle's start time.</param>
+ /// <param name="endTime">The subtitle's end time.</param>
+ public Subtitle (SubtitleProperties properties, TimeSpan startTime, TimeSpan endTime)
+ : this(properties, new SubtitleText(), new Style()) {
+
+ times.Start = startTime;
+ times.End = endTime;
+ }
+
+ /// <summary>Initializes a new instance of the <see cref="Subtitle" /> class, given the
+ /// global subtitles' properties and its start and end frames.</summary>
+ /// <param name="properties">The subtitles' properties.</param>
+ /// <param name="startFrame">The subtitle's start frame.</param>
+ /// <param name="endFrame">The subtitle's end frame.</param>
+ public Subtitle (SubtitleProperties properties, int startFrame, int endFrame)
+ : this(properties, new SubtitleText(), new Style()) {
+
+ frames.Start = startFrame;
+ frames.End = endFrame;
+ }
+
+ /// <summary>Initializes a new instance of the <see cref="Subtitle" /> class, given the
+ /// global subtitles' properties.</summary>
+ /// <param name="properties">The subtitles' properties.</param>
+ public Subtitle (SubtitleProperties properties)
+ : this(properties, new SubtitleText(), new Style()){
+ }
+
+ /// <summary>The subtitle's text.</summary>
+ public SubtitleText Text {
+ get { return text; }
+ set { text = value; }
+ }
+
+ /// <summary>The subtitle's translated text.</summary>
+ public SubtitleText Translation {
+ get {
+ if (translation == null)
+ translation = new SubtitleText();
+
+ return translation;
+ }
+ }
+
+ /// <summary>The subtitle's text style.</summary>
+ public Style Style {
+ get { return style; }
+ set { style = value; }
+ }
+
+ /// <summary>The subtitle's times.</summary>
+ public Times Times {
+ get { return times; }
+ }
+
+ /// <summary>The subtitle's frames.</summary>
+ public Frames Frames {
+ get { return frames; }
+ }
+
+ public override string ToString () {
+ return "* " + Times + " (" + Frames + ") " + Style + "\n" + Text.ToString();
+ }
+
+ /* Internal properties */
+
+ internal SubtitleProperties Properties {
+ set { properties = value; }
+ }
+
+ /* Internal methods */
+
+ internal void UpdateFramesFromTimes (float frameRate) {
+ UpdateStartFrameFromTimes(frameRate);
+ UpdateEndFrameFromTimes(frameRate);
+ }
+
+ internal void UpdateFramesFromTimes () {
+ UpdateStartFrameFromTimes();
+ UpdateEndFrameFromTimes();
+ }
+
+ internal void UpdateTimesFromFrames (float frameRate) {
+ UpdateStartTimeFromFrames(frameRate);
+ UpdateEndTimeFromFrames(frameRate);
+ }
+
+ internal void UpdateTimesFromFrames () {
+ UpdateStartTimeFromFrames();
+ UpdateEndTimeFromFrames();
+ }
+
+ internal void UpdateStartFrameFromTimes (float frameRate) {
+ frames.PreciseStart = TimingUtil.TimeToFrames(times.PreciseStart, frameRate);
+ }
+
+ internal void UpdateStartFrameFromTimes () {
+ UpdateStartFrameFromTimes(properties.CurrentFrameRate);
+ }
+
+ internal void UpdateEndFrameFromTimes (float frameRate) {
+ frames.PreciseEnd = TimingUtil.TimeToFrames(times.PreciseEnd, frameRate);
+ }
+
+ internal void UpdateEndFrameFromTimes () {
+ UpdateEndFrameFromTimes(properties.CurrentFrameRate);
+ }
+
+ internal void UpdateStartTimeFromFrames (float frameRate) {
+ times.PreciseStart = TimingUtil.FramesToTime(frames.PreciseStart, frameRate);
+ }
+
+ internal void UpdateStartTimeFromFrames () {
+ UpdateStartTimeFromFrames(properties.CurrentFrameRate);
+ }
+
+ internal void UpdateEndTimeFromFrames (float frameRate) {
+ times.PreciseEnd = TimingUtil.FramesToTime(frames.PreciseEnd, frameRate);
+ }
+
+ internal void UpdateEndTimeFromFrames () {
+ UpdateEndTimeFromFrames(properties.CurrentFrameRate);
+ }
+
+ internal void ClearTranslation () {
+ translation = null;
+ }
+
+}
+
+}
diff --git a/src/SubLib/Core/Domain/SubtitleCollection.cs b/src/SubLib/Core/Domain/SubtitleCollection.cs
new file mode 100644
index 0000000..47696ea
--- /dev/null
+++ b/src/SubLib/Core/Domain/SubtitleCollection.cs
@@ -0,0 +1,168 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System;
+using System.Collections;
+
+namespace SubLib.Core.Domain {
+
+/// <summary>A container that represents all the subtitles.</summary>
+public class SubtitleCollection {
+ private ArrayList subtitles = new ArrayList();
+
+ /// <summary>The number of subtitles in the collection.</summary>
+ public int Count {
+ get { return subtitles.Count; }
+ }
+
+ /// <summary>Returns an enumerator that can iterate through the collection.</summary>
+ /// <returns>An <see cref="IEnumerator" /> for the entire <see cref="SubtitleCollection" />.</returns>
+ public IEnumerator GetEnumerator () {
+ return subtitles.GetEnumerator();
+ }
+
+ public Subtitle this [int index] {
+ get {
+ try {
+ return subtitles[index] as Subtitle;
+ }
+ catch (ArgumentOutOfRangeException) {
+ return null;
+ }
+ }
+ }
+
+ /// <summary>Returns the subtitle at the specified index.</summary>
+ /// <param name="index">The zero-based subtitle's index.</param>
+ /// <returns>The subtitle at the specified index, or null in case the index is invalid.</returns>
+ public Subtitle Get (int index) {
+ if ((index >= 0) && (index < Count))
+ return (Subtitle)subtitles[index];
+ else
+ return null;
+ }
+
+ /// <summary>Adds a subtitle to the end of the collection.</summary>
+ /// <param name="subtitle">The subtitle to add.</param>
+ public void Add (Subtitle subtitle){
+ subtitles.Add(subtitle);
+ }
+
+ /// <summary>Adds a subtitle to the collection, inserting it at the specified index.</summary>
+ /// <param name="subtitle">The subtitle to add.</param>
+ /// <param name="index">The zero-based index at which the subtitle should be inserted.</param>
+ public void Add (Subtitle subtitle, int index){
+ subtitles.Insert(index, subtitle);
+ }
+
+ /// <summary>Creates a subtitle based on the subtitle at the specified index and adds it to the
+ /// collection, inserting it right before that index.</summary>
+ /// <remarks>The newly created subtitle's times will be based on the specified subtitle. Its end
+ /// time will be the start time of the existing subtitle minus <see cref="SubtitleConstants.MinTimeBetweenSubtitles" />.
+ /// Its duration will be <see cref="SubtitleConstants.MaxSingleLineSubtitleDuration" />. Both times will be wrapped to
+ /// zero if they are less than zero.</remarks>
+ /// <param name="index">The zero-based index before which the subtitle should be inserted.</param>
+ /// <param name="subtitleProperties">The SubtitleProperties of the subtitles.</param>
+ /// <returns>True if the subtitle could be added, false otherwise.</returns>
+ public bool AddNewBefore (int index, SubtitleProperties subtitleProperties) {
+ Subtitle existing = Get(index);
+ if (existing == null)
+ return false;
+
+ TimeSpan subtitleEnd = existing.Times.Start - TimeSpan.FromSeconds(SubtitleConstants.MinTimeBetweenSubtitles);
+ if (subtitleEnd < TimeSpan.Zero)
+ subtitleEnd = TimeSpan.FromSeconds(0);
+
+ TimeSpan subtitleStart = subtitleEnd - TimeSpan.FromSeconds(SubtitleConstants.MaxSingleLineSubtitleDuration);
+ if (subtitleStart < TimeSpan.Zero)
+ subtitleStart = TimeSpan.FromSeconds(0);
+
+ Subtitle subtitle = new Subtitle(subtitleProperties, subtitleStart, subtitleEnd);
+ Add(subtitle, index);
+ return true;
+ }
+
+ /// <summary>Creates a subtitle based on the subtitle at the specified index and adds it to the
+ /// collection, inserting it right after that index.</summary>
+ /// <remarks>The newly created subtitle's times will be based on the specified subtitle. Its start
+ /// time will be the start time of the existing subtitle plus <see cref="SubtitleConstants.MinTimeBetweenSubtitles" />.
+ /// Its duration will be <see cref="SubtitleConstants.MaxSingleLineSubtitleDuration" />.</remarks>
+ /// <param name="index">The zero-based index after which the subtitle should be inserted.</param>
+ /// <param name="subtitleProperties">The SubtitleProperties of the subtitles.</param>
+ /// <returns>True if the subtitle could be added, false otherwise.</returns>
+ public bool AddNewAfter (int index, SubtitleProperties subtitleProperties) {
+ Subtitle existing = Get(index);
+ if (existing == null)
+ return false;
+
+ TimeSpan subtitleStart = existing.Times.End + TimeSpan.FromSeconds(SubtitleConstants.MinTimeBetweenSubtitles);
+ TimeSpan subtitleEnd = subtitleStart + TimeSpan.FromSeconds(SubtitleConstants.MaxSingleLineSubtitleDuration);
+ Subtitle subtitle = new Subtitle(subtitleProperties, subtitleStart, subtitleEnd);
+ Add(subtitle, index + 1);
+ return true;
+ }
+
+ /// <summary>Creates a subtitle and adds it to the collection, inserting it at the specified index.</summary>
+ /// <remarks>The newly created subtitle's start time will be zero and its duration will be
+ /// <see cref="SubtitleConstants.MaxSingleLineSubtitleDuration" />.</remarks>
+ /// <param name="index">The zero-based index at which the subtitle should be inserted.</param>
+ /// <param name="subtitleProperties">The SubtitleProperties of the subtitles.</param>
+ /// <returns>True if the subtitle could be added, false otherwise.</returns>
+ public bool AddNewAt (int index, SubtitleProperties subtitleProperties) {
+ if ((index < 0) || (index > Count))
+ return false;
+
+ TimeSpan subtitleStart = TimeSpan.FromSeconds(0);
+ TimeSpan subtitleEnd = TimeSpan.FromSeconds(SubtitleConstants.MaxSingleLineSubtitleDuration);
+ Subtitle subtitle = new Subtitle(subtitleProperties, subtitleStart, subtitleEnd);
+ Add(subtitle, index);
+ return true;
+ }
+
+ /// <summary>Checks whether a subtitle with the specified index exists in the collection.</summary>
+ /// <param name="index">The zero-based index.</param>
+ /// <returns>Whether the index is contained within the collection.</returns>
+ public bool Contains (int index) {
+ return (index >= 0) && (index < Count);
+ }
+
+ /// <summary>Removes a subtitle from the collection, given its index.</summary>
+ /// <param name="index">The zero-based index of the subtitle to be removed.</param>
+ public void Remove (int index) {
+ subtitles.RemoveAt(index);
+ }
+
+ public override string ToString(){
+ string result = "\t* SUBTITLE LIST *\n";
+ foreach(Subtitle subtitle in subtitles){
+ result += subtitle.ToString();
+ }
+ return result;
+ }
+
+ /* Internal methods */
+
+ internal void SetPropertiesForAll (SubtitleProperties properties) {
+ foreach (Subtitle subtitle in subtitles)
+ subtitle.Properties = properties;
+ }
+
+}
+
+}
diff --git a/src/SubLib/Core/Domain/SubtitleConstants.cs b/src/SubLib/Core/Domain/SubtitleConstants.cs
new file mode 100644
index 0000000..922ac0d
--- /dev/null
+++ b/src/SubLib/Core/Domain/SubtitleConstants.cs
@@ -0,0 +1,95 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2006-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+namespace SubLib.Core.Domain {
+
+/// <summary>Contains constants for a set of subtitling parameters.</summary>
+public class SubtitleConstants {
+
+ /// <summary>The distance of the subtitles to the sides of the screen, in percent of screen dimensions.</summary>
+ /// <remarks>The value of this property is 1/12.</remarks>
+ public const float DistanceFromBottomFactor = 1/12;
+
+ /// <summary>The maximum number of lines that should be allowed.</summary>
+ /// <remarks>The value of this property is 2.</remarks>
+ public const int MaxLineCount = 2;
+
+ /// <summary>The maximum number of characters per line.</summary>
+ /// <remarks>The value of this property is 35.</remarks>
+ public const int MaxCharactersPerLine = 35;
+
+ /// <summary>The maximum number of words per line.</summary>
+ /// <remarks>The value of this property is 7.</remarks>
+ public const int MaxWordsPerLine = 7;
+
+ /// <summary>The lower bound on the average reading speed, in words per minute.</summary>
+ /// <remarks>The value of this property is 150.</remarks>
+ public const int MinAverageReadingWordsPerMinute = 150;
+
+ /// <summary>The upper bound on the average reading speed, in words per minute.</summary>
+ /// <remarks>The value of this property is 180.</remarks>
+ public const int MaxAverageReadingWordsPerMinute = 180;
+
+ /// <summary>The average reading speed, in words per minute.</summary>
+ /// <remarks>The value of this property is 150.</remarks>
+ public const int AverageReadingWordsPerMinute = 165;
+
+ /// <summary>The lower bound on the average reading speed, in words per second.</summary>
+/// <remarks>The value of this property is 2.5.</remarks>
+ public const float MinAverageReadingWordsPerSecond = 2.5f;
+
+ /// <summary>The upper bound on the average reading speed, in words per second.</summary>
+/// <remarks>The value of this property is 3.</remarks>
+ public const float MaxAverageReadingWordsPerSecond = 3;
+
+ /// <summary>The average reading speed, in words per second.</summary>
+ /// <remarks>The value of this property is 2.75.</remarks>
+ public const float AverageReadingWordsPerSecond = 2.75f;
+
+ /// <summary>The maximum duration of a full single-line subtitle, in seconds.</summary>
+ /// <remarks>The value of this property is 3.5.</remarks>
+ public const float MaxSingleLineSubtitleDuration = 3.5f;
+
+ /// <summary>The maximum duration of a full two-line subtitle, in seconds.</summary>
+ /// <remarks>The value of this property is 6.</remarks>
+ public const float MaxTwoLineSubtitleDuration = 6;
+
+ /// <summary>The duration of a single-word subtitle, in seconds.</summary>
+ /// <remarks>The value of this property is 1.5.</remarks>
+ public const float SingleWordSubtitleDuration = 1.5f;
+
+ /// <summary>The amount of time the subtitle should appear after the initiation of the utterance, in seconds.</summary>
+ /// <remarks>The value of this property is 0.25.</remarks>
+ public const float LeadingInTime = 0.25f;
+
+ /// <summary>The maximum amount of time the subtitle should be left on the screen after the end of the utterance, in seconds.</summary>
+ /// <remarks>The value of this property is 2.</remarks>
+ public const float LaggingOutTime = 2;
+
+ /// <summary>The minimum amount of time between two consecutive subtitles, in seconds.</summary>
+ /// <remarks>The value of this property is 0.25.</remarks>
+ public const float MinTimeBetweenSubtitles = 0.25f;
+
+ /// <summary>The maximum number of sentences that should be allowed per subtitle.</summary>
+ /// <remarks>The value of this property is 2.</remarks>
+ public const int MaxSentencesPerSubtitle = 2;
+
+}
+
+}
\ No newline at end of file
diff --git a/src/SubLib/Core/Domain/SubtitleHeaders.cs b/src/SubLib/Core/Domain/SubtitleHeaders.cs
new file mode 100644
index 0000000..7b4dbd2
--- /dev/null
+++ b/src/SubLib/Core/Domain/SubtitleHeaders.cs
@@ -0,0 +1,536 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2006-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System;
+using System.IO;
+using System.Text;
+
+namespace SubLib.Core.Domain {
+
+/// <summary>Represents the headers of the supported subtitle formats.</summary>
+public class SubtitleHeaders {
+
+ private SubtitleHeadersSubViewer1 subViewer1 = null;
+ private SubtitleHeadersSubViewer2 subViewer2 = null;
+ private SubtitleHeadersMPSub mPSub = null;
+ private SubtitleHeadersSubStationAlphaASS subStationAlphaASS = null;
+ private SubtitleHeadersKaraokeLyricsLRC karaokeLyricsLRC = null;
+ private SubtitleHeadersKaraokeLyricsVKT karaokeLyricsVKT = null;
+
+ /* Headers are initialized only if and when they're accessed */
+
+ /// <summary>The headers for the SubViewer 1.0 subtitle type.</summary>
+ public SubtitleHeadersSubViewer1 SubViewer1 {
+ get {
+ if (subViewer1 == null)
+ subViewer1 = new SubtitleHeadersSubViewer1();
+
+ return subViewer1;
+ }
+ }
+
+ /// <summary>The headers for the SubViewer 2.0 subtitle type.</summary>
+ public SubtitleHeadersSubViewer2 SubViewer2 {
+ get {
+ if (subViewer2 == null)
+ subViewer2 = new SubtitleHeadersSubViewer2();
+
+ return subViewer2;
+ }
+ }
+
+ /// <summary>The headers for the MPSub subtitle type.</summary>
+ public SubtitleHeadersMPSub MPSub {
+ get {
+ if (mPSub == null)
+ mPSub = new SubtitleHeadersMPSub();
+
+ return mPSub;
+ }
+ }
+
+ /// <summary>The headers for the Sub Station Alpha and Advanced Sub Station Alpha subtitle types.</summary>
+ public SubtitleHeadersSubStationAlphaASS SubStationAlphaASS {
+ get {
+ if (subStationAlphaASS == null)
+ subStationAlphaASS = new SubtitleHeadersSubStationAlphaASS();
+
+ return subStationAlphaASS;
+ }
+ }
+
+ /// <summary>The headers for the Karaoke Lyrics LRC subtitle type.</summary>
+ public SubtitleHeadersKaraokeLyricsLRC KaraokeLyricsLRC {
+ get {
+ if (karaokeLyricsLRC == null)
+ karaokeLyricsLRC = new SubtitleHeadersKaraokeLyricsLRC();
+
+ return karaokeLyricsLRC;
+ }
+ }
+
+ /// <summary>The headers for the Karaoke Lyrics VKT subtitle type.</summary>
+ public SubtitleHeadersKaraokeLyricsVKT KaraokeLyricsVKT {
+ get {
+ if (karaokeLyricsVKT == null)
+ karaokeLyricsVKT = new SubtitleHeadersKaraokeLyricsVKT();
+
+ return karaokeLyricsVKT;
+ }
+ }
+
+ public override string ToString() {
+ return "\t**** SUBTITLE HEADERS ****\t\n" +
+ (subViewer1 != null ? subViewer1.ToString() : "! SubViewer 1.0 not used") + "\n" +
+ (subViewer2 != null ? subViewer2.ToString() : "! SubViewer 2.0 not used") + "\n" +
+ (mPSub != null ? mPSub.ToString() : "! MPSub not used") + "\n" +
+ (subStationAlphaASS != null ? subStationAlphaASS.ToString() : "! SubStationAlpha and ASS not used") + "\n" +
+ (karaokeLyricsLRC != null ? karaokeLyricsLRC.ToString() : "! Karaoke Lyrics LRC not used") + "\n" +
+ (karaokeLyricsVKT != null ? karaokeLyricsVKT.ToString() : "! Karaoke Lyrics VKT not used");
+ }
+
+}
+
+/// <summary>Represents the headers of the SubViewer 1.0 subtitle format.</summary>
+public class SubtitleHeadersSubViewer1 {
+ private string title = String.Empty;
+ private string author = String.Empty;
+ private string source = String.Empty;
+ private string program = String.Empty;
+ private string filePath = String.Empty;
+ private int delay = 0;
+ private int cdTrack = 0;
+
+ /// <summary>The movie's title.</summary>
+ public string Title {
+ get { return title; }
+ set { title = value; }
+ }
+
+ /// <summary>The subtitles' author.</summary>
+ public string Author {
+ get { return author; }
+ set { author = value; }
+ }
+
+ /// <summary>The subtitles' source.</summary>
+ public string Source {
+ get { return source; }
+ set { source = value; }
+ }
+
+ /// <summary>The name of the subtitles' program.</summary>
+ public string Program {
+ get { return program; }
+ set { program = value; }
+ }
+
+ /// <summary>The subtitles' file path.</summary>
+ public string FilePath {
+ get { return filePath; }
+ set { filePath = value; }
+ }
+
+ /// <summary>The delay of the subtitles.</summary>
+ public int Delay {
+ get { return delay; }
+ set { delay = value; }
+ }
+
+ /// <summary>The delay of the subtitles as text.</summary>
+ public string DelayAsText {
+ get { return delay.ToString(); }
+ set {
+ try {
+ delay = Convert.ToInt32(value);
+ }
+ catch (Exception) {
+ }
+ }
+ }
+
+ /// <summary>The CD track of the subtitles.</summary>
+ public int CDTrack {
+ get { return cdTrack; }
+ set { cdTrack = value; }
+ }
+
+ /// <summary>The CD track of the subtitles as text.</summary>
+ public string CDTrackAsText {
+ get { return cdTrack.ToString(); }
+ set {
+ try {
+ cdTrack = Convert.ToInt32(value);
+ }
+ catch (Exception) {
+ }
+ }
+ }
+
+ public override string ToString() {
+ return "\t** SubViewer 1.0 Headers **\n" +
+ "Title: " + title + ", Author: " + author + ", Source: " + source + ", Program: " + program +
+ ", FilePath: " + filePath + ", Delay: " + delay + ", CD Track: " + cdTrack;
+ }
+
+}
+
+/// <summary>Represents the headers of the SubViewer 2.0 subtitle format.</summary>
+public class SubtitleHeadersSubViewer2 : SubtitleHeadersSubViewer1 {
+ private string comment = String.Empty;
+ private string fontColor = "&HFFFFFF";
+ private string fontStyle = "bd";
+ private int fontSize = 24;
+ private string fontName = "Tahoma";
+
+
+ /// <summary>A comment on the subtitles.</summary>
+ public string Comment {
+ get { return comment; }
+ set { comment = value; }
+ }
+
+ /// <summary>The subtitles' font color.</summary>
+ public string FontColor {
+ get { return fontColor; }
+ set { fontColor = value; }
+ }
+
+ /// <summary>The subtitles' font style.</summary>
+ public string FontStyle {
+ get { return fontStyle; }
+ set { fontStyle = value; }
+ }
+
+ /// <summary>The subtitles' font size.</summary>
+ public int FontSize {
+ get { return fontSize; }
+ set { fontSize = value; }
+ }
+
+ /// <summary>The subtitles' font size as text.</summary>
+ public string FontSizeAsText {
+ get { return fontSize.ToString(); }
+ set {
+ try {
+ fontSize = Convert.ToInt32(value);
+ }
+ catch (Exception) {
+ }
+ }
+ }
+
+ /// <summary>The subtitles' font name.</summary>
+ public string FontName {
+ get { return fontName; }
+ set { fontName = value; }
+ }
+
+ public override string ToString() {
+ return "\t** SubViewer 2.0 Headers **\n" +
+ "Base " + base.ToString() + "\n" +
+ "FontColor: " + fontColor + ", FontStyle: " + fontStyle + ", FontSize: " + fontSize + ", FontName: " + fontName;
+ }
+}
+
+/// <summary>Represents the headers of the MPSub subtitle format.</summary>
+public class SubtitleHeadersMPSub {
+ private string title = String.Empty;
+ private string file = String.Empty;
+ private string author = String.Empty;
+ private string mediaType = "VIDEO";
+ private string note = String.Empty;
+
+
+ /// <summary>The movie's title.</summary>
+ public string Title {
+ get { return title; }
+ set { title = value; }
+ }
+
+ /// <summary>The File properties, in the format 'size,md5'.</summary>
+ public string File {
+ get { return file; }
+ set { file = value; }
+ }
+
+ /// <summary>The subtitles' author.</summary>
+ public string Author {
+ get { return author; }
+ set { author = value; }
+ }
+
+ /// <summary>The Media Type of the subtitles, which can be 'VIDEO' or 'AUDIO'.</summary>
+ /// <remarks>This property is only set if the value is 'VIDEO' or 'AUDIO'. It's case insensitive.</remarks>
+ public string MediaType {
+ get { return mediaType; }
+ set {
+ string type = value.ToUpper();
+ if (type.Equals("VIDEO") || type.Equals("AUDIO"))
+ mediaType = type;
+ }
+ }
+
+ /// <summary>A note on the subtitles.</summary>
+ public string Note {
+ get { return note; }
+ set { note = value; }
+ }
+
+ public override string ToString() {
+ return "\t** MPSub Headers **\n" +
+ "Title: " + title + ", File: " + file + ", Author: " + author + ", MediaType: " + mediaType + ", Note: " + note;
+ }
+
+}
+
+/// <summary>Represents the headers of the Sub Station Alpha and Advanced Sub Station Alpha subtitle formats.</summary>
+public class SubtitleHeadersSubStationAlphaASS {
+ private string title = String.Empty;
+ private string originalScript = "<unknown>";
+ private string originalTranslation = String.Empty;
+ private string originalEditing = String.Empty;
+ private string originalTiming = String.Empty;
+ private string originalScriptChecking = String.Empty;
+ private string scriptUpdatedBy = String.Empty;
+ private string collisions = String.Empty;
+ private int playResX = 0;
+ private int playResY = 0;
+ private int playDepth = 0;
+ private string timer = String.Empty;
+
+ /// <summary>The movie's title.</summary>
+ public string Title {
+ get { return title; }
+ set { title = value; }
+ }
+
+ /// <summary>The Original Script of the subtitles.</summary>
+ public string OriginalScript {
+ get { return originalScript; }
+ set { originalScript = value; }
+ }
+
+ /// <summary>The Original Translation of the subtitles.</summary>
+ public string OriginalTranslation {
+ get { return originalTranslation; }
+ set { originalTranslation = value; }
+ }
+
+ /// <summary>The Original Editing of the subtitles.</summary>
+ public string OriginalEditing {
+ get { return originalEditing; }
+ set { originalEditing = value; }
+ }
+
+ /// <summary>The Original Timing of the subtitles.</summary>
+ public string OriginalTiming {
+ get { return originalTiming; }
+ set { originalTiming = value; }
+ }
+
+ /// <summary>The Original Script Checking of the subtitles.</summary>
+ public string OriginalScriptChecking {
+ get { return originalScriptChecking; }
+ set { originalScriptChecking = value; }
+ }
+
+ /// <summary>The Script Updated By of the subtitles.</summary>
+ public string ScriptUpdatedBy {
+ get { return scriptUpdatedBy; }
+ set { scriptUpdatedBy = value; }
+ }
+
+ /// <summary>The Collisions of the subtitles.</summary>
+ public string Collisions {
+ get { return collisions; }
+ set { collisions = value; }
+ }
+
+ /// <summary>The PlayResX of the subtitles.</summary>
+ public int PlayResX {
+ get { return playResX; }
+ set { playResX = value; }
+ }
+
+ /// <summary>The PlayResX of the subtitles as text.</summary>
+ public string PlayResXAsText {
+ get { return playResX.ToString(); }
+ set {
+ try {
+ playResX = Convert.ToInt32(value);
+ }
+ catch (Exception) {
+ }
+ }
+ }
+
+ /// <summary>The PlayResY of the subtitles.</summary>
+ public int PlayResY {
+ get { return playResY; }
+ set { playResY = value; }
+ }
+
+ /// <summary>The PlayResY of the subtitles as text.</summary>
+ public string PlayResYAsText {
+ get { return playResY.ToString(); }
+ set {
+ try {
+ playResY = Convert.ToInt32(value);
+ }
+ catch (Exception) {
+ }
+ }
+ }
+
+ /// <summary>The PlayDepth of the subtitles.</summary>
+ public int PlayDepth {
+ get { return playDepth; }
+ set { playDepth = value; }
+ }
+
+ /// <summary>The PlayResY of the subtitles as text.</summary>
+ public string PlayDepthAsText {
+ get { return playDepth.ToString(); }
+ set {
+ try {
+ playDepth = Convert.ToInt32(value);
+ }
+ catch (Exception) {
+ }
+ }
+ }
+
+ /// <summary>The Timer of the subtitles.</summary>
+ public string Timer {
+ get { return timer; }
+ set { timer = value; }
+ }
+
+ public override string ToString() {
+ return "\t** SubStationAlpha and Advanced SubStationAlpha Headers **\n" +
+ "Title: " + title + ", Original Script: " + originalScript + ", Original Translation: " + originalTranslation +
+ ", Original Editing: " + originalEditing + ", Original Timing: " + originalTiming +
+ ", Original Script Checking: " + originalScriptChecking + ", Script Updated By: " + scriptUpdatedBy +
+ ", Collisions: " + collisions + ", PlayResX: " + playResX + ", PlayResY: " + playResY +
+ ", PlayDepth: " + playDepth + ", Timer: " + timer;
+ }
+
+}
+
+/// <summary>Represents the headers of the Karaoke Lyrics LRC subtitle format.</summary>
+public class SubtitleHeadersKaraokeLyricsLRC {
+ private string title = String.Empty;
+ private string author = String.Empty;
+ private string artist = String.Empty;
+ private string album = String.Empty;
+ private string maker = String.Empty;
+ private string version = String.Empty;
+ private string program = String.Empty;
+
+ /// <summary>The movie's title.</summary>
+ public string Title {
+ get { return title; }
+ set { title = value; }
+ }
+
+ /// <summary>The subtitles' author.</summary>
+ public string Author {
+ get { return author; }
+ set { author = value; }
+ }
+
+ /// <summary>The subtitles' artist.</summary>
+ public string Artist {
+ get { return artist; }
+ set { artist = value; }
+ }
+
+ /// <summary>The subtitles' album.</summary>
+ public string Album {
+ get { return album; }
+ set { album = value; }
+ }
+
+ /// <summary>The subtitles' file maker.</summary>
+ public string Maker {
+ get { return maker; }
+ set { maker = value; }
+ }
+
+ /// <summary>The version of the subtitles.</summary>
+ public string Version {
+ get { return version; }
+ set { version = value; }
+ }
+
+ /// <summary>The name of the subtitles' program.</summary>
+ public string Program {
+ get { return program; }
+ set { program = value; }
+ }
+
+ public override string ToString() {
+ return "\t** Karaoke Lyrics LRC Headers **\n" +
+ "Title: " + title + ", Author: " + author + ", Artist: " + artist +
+ ", Maker: " + maker + ", Version: " + version + ", Program: " + program;
+ }
+
+}
+
+/// <summary>Represents the headers of the Karaoke Lyrics VKT subtitle format.</summary>
+public class SubtitleHeadersKaraokeLyricsVKT {
+ private string author = String.Empty;
+ private string frameRate = String.Empty;
+ private string source = String.Empty;
+ private string date = DateTime.Today.ToString("yyyy-MM-dd");
+
+ /// <summary>The subtitles' author.</summary>
+ public string Author {
+ get { return author; }
+ set { author = value; }
+ }
+
+ /// <summary>The movie's frame rate.</summary>
+ public string FrameRate {
+ get { return frameRate; }
+ set { frameRate = value; }
+ }
+
+ /// <summary>The video file path.</summary>
+ public string Source {
+ get { return source; }
+ set { source = value; }
+ }
+
+ /// <summary>The subtitles' date.</summary>
+ public string Date {
+ get { return date; }
+ set { date = value; }
+ }
+
+ public override string ToString() {
+ return "\t** Karaoke Lyrics VKT Headers **\n" +
+ "Author: " + author + ", FrameRate: " + frameRate +
+ ", Source: " + source + ", Date: " + date;
+ }
+
+}
+
+}
diff --git a/src/SubLib/Core/Domain/SubtitleProperties.cs b/src/SubLib/Core/Domain/SubtitleProperties.cs
new file mode 100644
index 0000000..cea89b4
--- /dev/null
+++ b/src/SubLib/Core/Domain/SubtitleProperties.cs
@@ -0,0 +1,90 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.IO.Input;
+using System;
+using System.IO;
+using System.Text;
+
+namespace SubLib.Core.Domain {
+
+/// <summary>Represents the properties of subtitles.</summary>
+/// <remarks>This class acts as a container which allows you to get and set a
+/// variety of properties. Some of these properties are used in syncronization
+/// and timing calculations.</remarks>
+public class SubtitleProperties {
+ private Headers headers = new Headers();
+
+ private float originalFrameRate = 25;
+ private float currentFrameRate = 25;
+
+
+ public SubtitleProperties () {
+ }
+
+ public SubtitleProperties (Headers headers, float originalFrameRate, float currentFrameRate) {
+ this.headers = headers;
+ this.originalFrameRate = originalFrameRate;
+ this.currentFrameRate = currentFrameRate;
+ }
+
+ /// <summary>Initializes a new instance of the <see cref="SubtitleProperties" />
+ /// class, with defaults for all properties.</summary>
+ internal SubtitleProperties (ParsingProperties properties) {
+ headers = properties.Headers;
+ originalFrameRate = properties.OriginalFrameRate;
+ }
+
+
+ /// <summary>The headers used in some subtitle formats.</summary>
+ public Headers Headers {
+ get { return headers; }
+ }
+
+ /// <summary>The frame rate originally applied to the subtitles.</summary>
+ /// <remarks>When converting between frame rates, this is the frame rate of the subtitles
+ /// when they are opened. This is sometimes refered to as the input frame rate.</remarks>
+ public float OriginalFrameRate {
+ get { return originalFrameRate; }
+ }
+
+ /// <summary>The frame rate currently being used in the subtitles.</summary>
+ /// <remarks>When converting between frame rates, this is the target frame rate of the
+ /// subtitles. This is sometimes refered to as the output frame rate.</remarks>
+ public float CurrentFrameRate {
+ get { return currentFrameRate; }
+ }
+
+ public override string ToString () {
+ return "Original FPS = " + originalFrameRate + ", Current FPS = " + currentFrameRate + "\n" + headers.ToString();
+ }
+
+ /* Internal members */
+
+ internal void SetCurrentFrameRate (float frameRate) {
+ currentFrameRate = frameRate;
+ }
+
+ internal void SetOriginalFrameRate (float frameRate) {
+ originalFrameRate = frameRate;
+ }
+
+}
+
+}
diff --git a/src/SubLib/Core/Domain/SubtitleText.cs b/src/SubLib/Core/Domain/SubtitleText.cs
new file mode 100644
index 0000000..ccee4ff
--- /dev/null
+++ b/src/SubLib/Core/Domain/SubtitleText.cs
@@ -0,0 +1,195 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System;
+using System.Collections;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace SubLib.Core.Domain {
+
+//TODO this can be optimized
+/// <summary>Represents the text of a subtitle.</summary>
+public class SubtitleText {
+ private ArrayList lines = new ArrayList();
+
+ /// <summary>Initializes a new instance of the <see cref="SubtitleText" /> class
+ /// with the specified text, line break and trimming option.</summary>
+ /// <param name="text">The subtitle text.</param>
+ /// <param name="lineBreak">The text substring that marks the end of lines.</param>
+ /// <param name="toTrimLines">Whether to trim every text line.</param>
+ public SubtitleText (string text, string lineBreak, bool toTrimLines) {
+ Set(text, lineBreak, toTrimLines);
+ }
+
+ /// <summary>Initializes a new instance of the <see cref="SubtitleText" /> class
+ /// with the specified text.</summary>
+ /// <remarks>Newline (\n) is used as the line break. The text lines are not trimmed.</remarks>
+ /// <param name="text">The subtitle text.</param>
+ public SubtitleText (string text) : this(text, "\n", false) {
+ }
+
+ /// <summary>Initializes a new instance of the <see cref="SubtitleText" /> class, with empty text.</summary>
+ public SubtitleText() {
+ }
+
+ /// <summary>Whether there is no text.</summary>
+ public bool IsEmpty {
+ get { return (lines.Count == 0); }
+ }
+
+ /// <summary>Gets the specified text line.</summary>
+ /// <param name="index">The zero-based line number index.</param>
+ /// <returns>The specified text line.</returns>
+ public string GetLine (int index) {
+ if ((index >= 0) && (index < lines.Count))
+ return lines[index] as string;
+ else
+ return String.Empty;
+ }
+
+ /// <summary>Gets the text lines merged with the specified line break.</summary>
+ /// <param name="lineBreak">The line break used to merge the text.</param>
+ /// <returns>The subtitle text.</returns>
+ public string Get (string lineBreak) {
+ string text = String.Empty;
+ IEnumerator textLines = lines.GetEnumerator();
+ if (textLines.MoveNext()){
+ text = (textLines.Current as string);
+ while (textLines.MoveNext())
+ text += lineBreak + (textLines.Current as string);
+ }
+ return text;
+ }
+
+ /// <summary>Gets the subtitle text.</summary>
+ /// <remarks>The text lines end with the new line (\n) char.</remarks>
+ /// <returns>The subtitle text.</returns>
+ public string Get () {
+ return Get("\n");
+ }
+
+ /// <summary>Gets the text lines merged with the specified line break and replaces those that are empty.</summary>
+ /// <param name="replacement">The text to replace empty lines with.</param>
+ /// <param name="lineBreak">The line break used to merge the text.</param>
+ /// <remarks>A subtitle line is considered empty if it has no characters.</remarks>
+ /// <returns>The subtitle text, after replacement.</returns>
+ public string GetReplaceEmptyLines (string replacement, string lineBreak) {
+ if (this.IsEmpty)
+ return replacement;
+
+ string text = String.Empty;
+ IEnumerator textLines = lines.GetEnumerator();
+ if (textLines.MoveNext()){
+ string line = (textLines.Current as string);
+ text = ReplaceLineIfEmpty(line, replacement);
+ while (textLines.MoveNext()) {
+ line = (textLines.Current as string);
+ text += lineBreak + ReplaceLineIfEmpty(line, replacement);
+ }
+ }
+ return text;
+ }
+
+ /// <summary>Gets the text lines and replaces those that are empty.</summary>
+ /// <param name="replacement">The text to replace empty lines with.</param>
+ /// <remarks>The text lines are merged by the newline (\n) char. A subtitle line is considered empty
+ /// if it has no characters.</remarks>
+ /// <returns>The subtitle text, after replacement.</returns>
+ public string GetReplaceEmptyLines (string replacement) {
+ return GetReplaceEmptyLines(replacement, "\n");
+ }
+
+ /// <summary>Gets and trims the text lines merged with the specified line break.</summary>
+ /// <param name="lineBreak">The line break used to merge the text.</param>
+ /// <remarks>A subtitle line is considered blank if it has only white spaces.</remarks>
+ /// <returns>The subtitle text, after trimming.</returns>
+ public string GetTrimLines (string lineBreak) {
+ string text = String.Empty;
+ IEnumerator textLines = lines.GetEnumerator();
+ if (textLines.MoveNext()){
+ string line = (textLines.Current as string);
+ line = line.Trim();
+ if (line != String.Empty)
+ text += line;
+
+ while (textLines.MoveNext()) {
+ line = (textLines.Current as string);
+ line = line.Trim();
+ if (line != String.Empty)
+ text += lineBreak + line;
+ }
+ }
+ return text;
+ }
+
+ /// <summary>Gets and trims the text lines.</summary>
+ /// <remarks>The text lines are merged by the newline (\n) char. A subtitle line is
+ /// considered blank ifit has only white spaces.</remarks>
+ /// <returns>The subtitle text, after trimming.</returns>
+ public string GetTrimLines () {
+ return GetTrimLines("\n");
+ }
+
+ /// <summary>Sets the subtitle text using the specified line break and trimming option.</summary>
+ /// <param name="text">The subtitle text.</param>
+ /// <param name="lineBreak">The text substring used to split the text in lines.</param>
+ /// <param name="toTrimLines">Whether to trim every text line.</param>
+ public void Set (string text, string lineBreak, bool toTrimLines) {
+ if (toTrimLines)
+ text = text.Trim();
+
+ string escapedLineBreak = Regex.Escape(lineBreak);
+ string spaceDelimiter = (toTrimLines ? @"\s*" : String.Empty);
+ string regexPattern = spaceDelimiter + @escapedLineBreak + spaceDelimiter;
+ string[] textLines = Regex.Split(text, regexPattern);
+ lines.Clear();
+ foreach (string textLine in textLines)
+ lines.Add(textLine);
+ }
+
+ /// <summary>Sets the subtitle text.</summary>
+ /// <remarks>Newline (\n) is used as the line break. The text lines are not trimmed.</remarks>
+ /// <param name="text">The subtitle text.</param>
+ public void Set (string text) {
+ Set(text, "\n", false);
+ }
+
+ public override string ToString() {
+ string result = String.Empty;
+ int lineNumber = 1;
+ foreach (string line in lines){
+ result += "\t" + lineNumber + ". " + line + "\n";
+ lineNumber++;
+ }
+ return result;
+ }
+
+ /* Private Methods */
+
+ private string ReplaceLineIfEmpty (string textLine, string replacement) {
+ if (textLine == String.Empty)
+ return replacement;
+ else
+ return textLine;
+ }
+
+}
+
+}
diff --git a/src/SubLib/Core/Domain/SubtitleTypeInfo.cs b/src/SubLib/Core/Domain/SubtitleTypeInfo.cs
new file mode 100644
index 0000000..ac83dd2
--- /dev/null
+++ b/src/SubLib/Core/Domain/SubtitleTypeInfo.cs
@@ -0,0 +1,118 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2006-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.IO.SubtitleFormats;
+using System;
+
+namespace SubLib.Core.Domain {
+
+/// <summary>Contains information about a subtitle file type.</summary>
+public class SubtitleTypeInfo : IComparable {
+ private string name;
+ private SubtitleType type;
+ private string[] extensions;
+
+
+ /// <summary>Initializes a new instance of the <see cref="SubtitleTypeInfo" /> class.</summary>
+ /// <param name="name">The name of the subtitle type.</param>
+ /// <param name="type">The subtitle type.</param>
+ /// <param name="extensions">The extensions the subtitle type uses.</param>
+ public SubtitleTypeInfo (string name, SubtitleType type, string[] extensions) {
+ this.name = name;
+ this.type = type;
+ this.extensions = extensions;
+ }
+
+ /// <summary>The name of the subtitle type.</summary>
+ public string Name {
+ get { return name; }
+ }
+
+ /// <summary>The subtitle type.</summary>
+ public SubtitleType Type {
+ get { return type; }
+ }
+
+ /// <summary>The extensions the subtitle type uses.</summary>
+ public string[] Extensions {
+ get { return extensions; }
+ }
+
+ /// <summary>A comma-separated list of the extensions the subtitle type uses.
+ /// The prefix "*." is added to every extension.</summary>
+ public string ExtensionsAsText {
+ get { return ExtensionsToText(); }
+ }
+
+ /// <summary>The preferred extension, which is the first on the list.</summary>
+ public string PreferredExtension {
+ get { return extensions[0]; }
+ }
+
+ /// <summary>Checks whether the specified extension is one of the extensions of the <see cref="SubtitleType" /></summary>
+ /// <param name="extension">The extension to search for.</param>
+ /// <returns>True if the extension was found, False otherwise.</returns>
+ public bool HasExtension (string extension) {
+ foreach (string typeExtension in extensions) {
+ if (typeExtension == extension)
+ return true;
+ }
+ return false;
+ }
+
+ /// <summary>Compares this instance with a specified object, based on the object names.
+ /// See <see cref="String.CompareTo(object)" /> for more information.</summary>
+ /// <param name="obj">The object to compare this class to.</param>
+ /// <returns>
+ /// <list type="table">
+ /// <listheader><term>Value</term><description>Condition</description></listheader>
+ /// <item><term>Less than zero</term><description>This instance is less than obj.</description></item>
+ /// <item><term>Zero</term><description>This instance is equal to obj.</description></item>
+ /// <item><term>Greater than zero</term><description>This instance is greater than obj, or obj is a
+ /// null reference.</description></item>
+ /// </list>
+ /// </returns>
+ public int CompareTo (object obj) {
+ return Name.CompareTo((obj as SubtitleTypeInfo).Name);
+ }
+
+ /* Internal members */
+
+ internal SubtitleTypeInfo (SubtitleFormat format) : this(format.Name, format.Type, format.Extensions) {
+ }
+
+ /* Private members */
+
+ private string ExtensionsToText () {
+ if (extensions == null)
+ return String.Empty;
+
+ string text = ExtensionToText(extensions[0]);
+ for (int count = 1 ; count < extensions.Length ; count++)
+ text += ", " + ExtensionToText(extensions[count]);
+
+ return text;
+ }
+
+ private string ExtensionToText (string extension) {
+ return "*." + extension;
+ }
+}
+
+}
diff --git a/src/SubLib/Core/Domain/Subtitles.cs b/src/SubLib/Core/Domain/Subtitles.cs
new file mode 100644
index 0000000..bdfb7e9
--- /dev/null
+++ b/src/SubLib/Core/Domain/Subtitles.cs
@@ -0,0 +1,114 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.IO.SubtitleFormats;
+using System;
+using System.Collections;
+using System.Globalization;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace SubLib.Core.Domain {
+
+/// <summary>Represents the root class of all the subtitles.</summary>
+/// <remarks>A <see cref="Subtitles" /> class is created using the <see cref="SubtitleFactory" />.</remarks>
+public class Subtitles {
+ private SubtitleCollection collection = null;
+ private SubtitleProperties properties = null;
+
+ /// <summary>A collection which contains the subtitles.</summary>
+ public SubtitleCollection Collection {
+ get { return collection; }
+ set { collection = value; }
+ }
+
+ /// <summary>The properties of the subtitles.</summary>
+ public SubtitleProperties Properties {
+ get { return properties; }
+ set { properties = value; }
+ }
+
+ /// <summary>Information about the available subtitle types.</summary>
+ public static SubtitleTypeInfo[] AvailableTypes {
+ get {
+ SubtitleFormat[] formats = BuiltInSubtitleFormats.SubtitleFormats;
+ SubtitleTypeInfo[] types = new SubtitleTypeInfo[formats.Length];
+ for (int count = 0 ; count < formats.Length ; count++)
+ types[count] = new SubtitleTypeInfo(formats[count]);
+
+ return types;
+ }
+ }
+
+ /// <summary>Information about the available subtitle types, sorted by their names.</summary>
+ public static SubtitleTypeInfo[] AvailableTypesSorted {
+ get {
+ SubtitleTypeInfo[] types = AvailableTypes;
+ Array.Sort(types);
+ return types;
+ }
+ }
+
+ /// <summary>Get information about an available subtitle type.</summary>
+ /// <param name="type">The subtitle type.</param>
+ /// <returns>The information about the specified subtitle type.</returns>
+ public static SubtitleTypeInfo GetAvailableType (SubtitleType type) {
+ SubtitleFormat format = BuiltInSubtitleFormats.GetFormat(type);
+ return new SubtitleTypeInfo(format);
+ }
+
+ public override string ToString(){
+ return Collection.ToString() + "\n-------------------------------------------\n" + Properties.ToString();
+ }
+
+ /* Internal members */
+
+ /// <summary>Initializes a new instance of the <see cref="Subtitles" /> class.</summary>
+ /// <param name="collection">A collection of subtitles.</param>
+ /// <param name="properties">The subtitles' properties.</param>
+ internal protected Subtitles (SubtitleCollection collection, SubtitleProperties properties) {
+ this.collection = collection;
+ this.properties = properties;
+ }
+
+ internal void UpdateFramesFromTimes (float frameRate) {
+ foreach (Subtitle subtitle in collection) {
+ subtitle.UpdateFramesFromTimes(frameRate);
+ }
+ }
+
+ internal void UpdateTimesFromFrames (float frameRate) {
+ foreach (Subtitle subtitle in collection) {
+ subtitle.UpdateTimesFromFrames(frameRate);
+ }
+ }
+
+ internal SubtitleText GetSubtitleText (int subtitleNumber, SubtitleTextType textType) {
+ Subtitle subtitle = collection[subtitleNumber];
+ if (textType == SubtitleTextType.Text)
+ return subtitle.Text;
+ else
+ return subtitle.Translation;
+ }
+
+
+}
+
+}
+
diff --git a/src/SubLib/Core/Domain/SyncPoint.cs b/src/SubLib/Core/Domain/SyncPoint.cs
new file mode 100644
index 0000000..46748ee
--- /dev/null
+++ b/src/SubLib/Core/Domain/SyncPoint.cs
@@ -0,0 +1,56 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System;
+
+namespace SubLib.Core.Domain {
+
+public class SyncPoint {
+ private int subtitleNumber = 0;
+ private Timing current = null;
+ private Timing correct = null;
+
+ public SyncPoint (int subtitleNumber, Timing current, Timing correct) {
+ this.subtitleNumber = subtitleNumber;
+ this.current = current;
+ this.correct = correct;
+ }
+
+ /* Properties */
+
+ public int SubtitleNumber {
+ get { return subtitleNumber; }
+ }
+
+ public Timing Current {
+ get { return current; }
+ }
+
+ public Timing Correct {
+ get { return correct; }
+ }
+
+ public int CompareCurrentTo (SyncPoint otherSyncPoint) {
+ return current.CompareTo(otherSyncPoint.Current);
+ }
+
+
+}
+
+}
diff --git a/src/SubLib/Core/Domain/SyncPoints.cs b/src/SubLib/Core/Domain/SyncPoints.cs
new file mode 100644
index 0000000..005f763
--- /dev/null
+++ b/src/SubLib/Core/Domain/SyncPoints.cs
@@ -0,0 +1,84 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2008-2009 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System;
+using System.Collections;
+
+namespace SubLib.Core.Domain {
+
+public class SyncPoints {
+ protected SortedList syncPoints = null;
+
+ public SyncPoints () {
+ this.syncPoints = new SortedList();
+ }
+
+ public SyncPoints (SortedList syncPoints) {
+ this.syncPoints = syncPoints;
+ }
+
+ /* Indexers */
+
+ public SyncPoint this [int index] {
+ get { return syncPoints.GetByIndex(index) as SyncPoint; }
+ }
+
+ /* Properties */
+
+ public int Count {
+ get { return syncPoints.Count; }
+ }
+
+ /* Public methods */
+
+ public SyncPoint Get (int index) {
+ return syncPoints.GetByIndex(index) as SyncPoint;
+ }
+
+ public int IndexOf (SyncPoint syncPoint) {
+ return syncPoints.IndexOfKey(syncPoint.SubtitleNumber);
+ }
+
+ public bool Contains (int subtitleNumber) {
+ return syncPoints.ContainsKey(subtitleNumber);
+ }
+
+ public bool Add (SyncPoint syncPoint) {
+ bool willReplace = Contains(syncPoint.SubtitleNumber);
+ syncPoints[syncPoint.SubtitleNumber] = syncPoint;
+ return willReplace;
+ }
+
+ public void Remove (int index) {
+ syncPoints.RemoveAt(index);
+ }
+
+ public IEnumerator GetEnumerator () {
+ return syncPoints.GetEnumerator();
+ }
+
+ public SyncPoints Clone () {
+ return new SyncPoints(syncPoints.Clone() as SortedList);
+ }
+
+
+
+}
+
+}
diff --git a/src/SubLib/Core/Domain/Times.cs b/src/SubLib/Core/Domain/Times.cs
new file mode 100644
index 0000000..597172c
--- /dev/null
+++ b/src/SubLib/Core/Domain/Times.cs
@@ -0,0 +1,131 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System;
+
+namespace SubLib.Core.Domain {
+
+/// <summary>Represents the times of a subtitle.</summary>
+/// <remarks><see cref="Times" /> and <see cref="Frames" /> always exist for any <see cref="Subtitle" />.
+/// This class is automatically constructed when constructing a <see cref="Subtitle" />.</remarks>
+public class Times {
+ private TimeSpan start = TimeSpan.Zero;
+ private TimeSpan end = TimeSpan.Zero;
+ private Subtitle subtitle = null;
+
+
+ /// <summary>The start time.</summary>
+ /// <remarks>Upon setting the start time, the start frame (<see cref="Frames.Start">Frames.Start</see>) is also updated based on
+ /// the <see cref="SubtitleProperties.CurrentFrameRate" />.</remarks>
+ public TimeSpan Start {
+ get { return PreciseStart; }
+ set {
+ PreciseStart = value;
+ subtitle.UpdateStartFrameFromTimes();
+ }
+ }
+
+ /// <summary>The end time.</summary>
+ /// <remarks>Upon setting the end time, the end frame (<see cref="Frames.End">Frames.End</see>) is also updated based on
+ /// the <see cref="SubtitleProperties.CurrentFrameRate" />.</remarks>
+ public TimeSpan End {
+ get { return PreciseEnd; }
+ set {
+ PreciseEnd = value;
+ subtitle.UpdateEndFrameFromTimes();
+ }
+ }
+
+ /// <summary>The time duration.</summary>
+ /// <remarks>Setting the duration maintains the start time and changes the end time.
+ /// Upon setting the duration, the end frame (<see cref="Frames.End">Frames.End</see>) is also updated based on
+ /// the <see cref="SubtitleProperties.CurrentFrameRate" />.</remarks>
+ public TimeSpan Duration {
+ get { return End - Start; }
+ set { End = Start + value; }
+ }
+
+ /// <summary>Shifts the subtitle with a specified time span.</summary>
+ /// <param name="time">The time span to shift the subtitle with, which can be positive or negative.</param>
+ public void Shift (TimeSpan time) {
+ PreciseStart += time;
+ PreciseEnd += time;
+ subtitle.UpdateFramesFromTimes();
+ }
+
+ public Times Clone () {
+ return MemberwiseClone() as Times;
+ }
+
+
+ public override string ToString() {
+ return Start + "->" + End;
+ }
+
+
+ /* Internal members */
+
+ internal Times (Subtitle subtitle) {
+ this.subtitle = subtitle;
+ }
+
+ internal Times (Subtitle subtitle, TimeSpan start, TimeSpan end) {
+ this.start = start;
+ this.end = end;
+ this.subtitle = subtitle;
+ }
+
+ /// <remarks>Doesn't update frames.</remarks>
+ internal TimeSpan PreciseStart {
+ get { return start; }
+ set { start = value; }
+ }
+
+ /// <remarks>Doesn't update frames.</remarks>
+ internal TimeSpan PreciseEnd {
+ get { return end; }
+ set { end = value; }
+ }
+
+ /// <remarks>Doesn't update frames.</remarks>
+ internal TimeSpan PreciseDuration {
+ get { return end - start; }
+ set { end = start + value; }
+ }
+
+ internal void Scale (double factor, TimeSpan baseTime) {
+ System.Console.WriteLine("Factor " + factor + " baseTime " + baseTime);
+ double baseMilliseconds = baseTime.TotalMilliseconds;
+
+ double start = PreciseStart.TotalMilliseconds;
+ double newStart = baseMilliseconds + ((start - baseMilliseconds) * factor);
+ PreciseStart = TimeSpan.FromMilliseconds(newStart);
+
+ double end = PreciseEnd.TotalMilliseconds;
+ double newEnd = baseMilliseconds + ((end - baseMilliseconds) * factor);
+ PreciseEnd = TimeSpan.FromMilliseconds(newEnd);
+
+ System.Console.WriteLine("Start " + start + ", newStart " + newStart + ", end " + end + ", newEnd " + newEnd);
+
+ subtitle.UpdateFramesFromTimes();
+ }
+
+}
+
+}
diff --git a/src/SubLib/Core/Domain/Timing.cs b/src/SubLib/Core/Domain/Timing.cs
new file mode 100644
index 0000000..92d5e9f
--- /dev/null
+++ b/src/SubLib/Core/Domain/Timing.cs
@@ -0,0 +1,52 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System;
+
+namespace SubLib.Core.Domain {
+
+public class Timing : IComparable {
+ private double frame = 0;
+ private TimeSpan time = TimeSpan.Zero;
+
+ public Timing (int frame, TimeSpan time) {
+ this.frame = frame;
+ this.time = time;
+ }
+
+ public int Frame {
+ get { return Convert.ToInt32(frame); }
+ }
+
+ public TimeSpan Time {
+ get { return time; }
+ }
+
+ public int CompareTo (object obj) {
+ if (!(obj is Timing))
+ throw new ArgumentException("Object is not of class Timing");
+
+ return time.CompareTo((obj as Timing).Time);
+ }
+
+
+
+}
+
+}
diff --git a/src/SubLib/Core/MatchEvaluationCounter.cs b/src/SubLib/Core/MatchEvaluationCounter.cs
new file mode 100644
index 0000000..90f4365
--- /dev/null
+++ b/src/SubLib/Core/MatchEvaluationCounter.cs
@@ -0,0 +1,51 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2006-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.Core {
+
+internal class MatchEvaluationCounter {
+ int count = 0; //The number of matches or times the evaluator was called
+ bool evaluationOccured = false; //Whether an evaluation occured
+ string replacement = String.Empty;
+
+ internal MatchEvaluationCounter (string replacement) {
+ this.replacement = replacement;
+ }
+
+ internal int Count {
+ get { return count; }
+ }
+
+ internal bool EvaluationOccured {
+ get { return evaluationOccured; }
+ set { evaluationOccured = value; }
+ }
+
+ internal string Evaluator (Match match) {
+ count++;
+ evaluationOccured = true;
+ return replacement;
+ }
+
+}
+
+}
\ No newline at end of file
diff --git a/src/SubLib/Core/Search/SearchOperator.cs b/src/SubLib/Core/Search/SearchOperator.cs
new file mode 100644
index 0000000..ccdf438
--- /dev/null
+++ b/src/SubLib/Core/Search/SearchOperator.cs
@@ -0,0 +1,311 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2006-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Collections;
+using System.Text.RegularExpressions;
+
+namespace SubLib.Core.Search {
+
+/// <summary>Performs search operations.</summary>
+public class SearchOperator {
+ private Subtitles subtitles = null;
+
+ public SearchOperator (Subtitles subtitles) {
+ this.subtitles = subtitles;
+ }
+
+ /* Public members */
+
+
+ /// <summary>Searches for text using the specified search options.</summary>
+ /// <param name="options">The search options.</param>
+ /// <returns>The search results, or null in case no results were found.</returns>
+ public SubtitleSearchResults Find (SubtitleSearchOptions options) {
+ System.Console.WriteLine("Finding " + options.Regex.ToString() + " from subtitle " + options.StartSubtitle + ", index " + options.StartIndex + ", type " + options.TextType);
+ if (options.Backwards)
+ return FindBackward(options);
+ else
+ return FindForward(options);
+ }
+
+ /// <summary>Replaces all occurences of some text with the specified replacement.</summary>
+ /// <param name="regex">A regular expression used to find the text to be replaced.</param>
+ /// <param name="replacement">The text that will be used as a replacement.</param>
+ /// <param name="replacedSubtitles">The numbers of the subtitles that were replaced.</param>
+ /// <param name="oldTexts">The texts of the subtitles that were replaced, before replacement was done.</param>
+ /// <remarks>The newline (\n) char is used as the line break.</remarks>
+ /// <returns>The number of replaced subtitles.</returns>
+ public int ReplaceAll (Regex regex, string replacement, out int[] replacedSubtitles, out string[] oldTexts) {
+ return ReplaceAll(regex, replacement, "\n", out replacedSubtitles, out oldTexts);
+ }
+
+ /// <summary>Replaces all occurences of some text with the specified replacement.</summary>
+ /// <param name="regex">A regular expression used to find the text to be replaced.</param>
+ /// <param name="replacement">The text that will be used as a replacement.</param>
+ /// <param name="lineBreak">The line break to use between multiple lines of text in each subtitle.</param>
+ /// <param name="replacedSubtitles">The numbers of the subtitles that were replaced.</param>
+ /// <param name="oldTexts">The texts of the subtitles that were replaced, before replacement was done.</param>
+ /// <remarks>The newline (\n) char is used as the line break.</remarks>
+ /// <returns>The number of replaced subtitles.</returns>
+ public int ReplaceAll (Regex regex, string replacement, string lineBreak, out int[] replacedSubtitles, out string[] oldTexts) {
+ ArrayList replaced = new ArrayList();
+ ArrayList texts = new ArrayList();
+ MatchEvaluationCounter counter = new MatchEvaluationCounter(replacement);
+ int subtitleNumber = 0;
+ foreach (Subtitle subtitle in subtitles.Collection) {
+ string oldText = subtitle.Text.Get(lineBreak);
+ counter.EvaluationOccured = false;
+ string newText = regex.Replace(oldText, counter.Evaluator);
+ if (counter.EvaluationOccured) {
+ replaced.Add(subtitleNumber);
+ texts.Add(oldText);
+ subtitle.Text.Set(newText, lineBreak, false);
+ counter.EvaluationOccured = false;
+ }
+ subtitleNumber++;
+ }
+
+ replacedSubtitles = (int[])replaced.ToArray(typeof(int));
+ oldTexts = (string[])texts.ToArray(typeof(string));
+ return counter.Count;
+ }
+
+ /// <summary>Finds the subtitle that contains the specified time position.</summary>
+ /// <param name="time">The time position, in seconds.</param>
+ /// <returns>The found subtitle number, or -1 if no subtitle was found.</returns>
+ public int FindWithTime (float time) {
+ SubtitleCollection collection = subtitles.Collection;
+
+ if (collection.Count == 0)
+ return -1;
+
+ for (int subtitleNumber = 0 ; subtitleNumber < collection.Count ; subtitleNumber++) {
+ Subtitle subtitle = collection[subtitleNumber];
+ double start = subtitle.Times.Start.TotalSeconds;
+ if (time < start)
+ continue;
+
+ double end = subtitle.Times.End.TotalSeconds;
+ if (time <= end)
+ return subtitleNumber;
+ }
+ return -1; // No subtitles were found
+ }
+
+
+ /* Private members */
+
+
+ /// <summary>Searches forward for text using the specified search options.</summary>
+ /// <param name="options">The search options.</param>
+ /// <returns>The search results, or null in case no results were found.</returns>
+ private SubtitleSearchResults FindForward (SubtitleSearchOptions options) {
+ SubtitleCollection collection = subtitles.Collection;
+
+ if (collection.Count == 0)
+ return null;
+
+ /* Search the startSubtitle subtitle starting at the startIndex */
+ SubtitleSearchResults results = FindInSubtitleFromIndex(options.StartSubtitle, options.LineBreak, options.Regex, options.StartIndex, options.TextType, options.Backwards);
+ if (results != null)
+ return results;
+
+ /* Iterate through the rest of the collection */
+ for (int subtitleNumber = options.StartSubtitle + 1 ; subtitleNumber < collection.Count ; subtitleNumber++) {
+ results = FindInSubtitle(subtitleNumber, options.LineBreak, options.Regex, options.Backwards);
+ if (results != null)
+ return results;
+ }
+
+ if (options.Wrap) {
+ /* Iterate from the beginning back to the subtitle */
+ for (int subtitleNumber = 0 ; subtitleNumber < options.StartSubtitle ; subtitleNumber++) {
+ results = FindInSubtitle(subtitleNumber, options.LineBreak, options.Regex, options.Backwards);
+ if (results != null)
+ return results;
+ }
+ /* Search the startSubtitle ending at the startIndex */
+ results = FindInSubtitleTillIndex(options.StartSubtitle, options.LineBreak, options.Regex, options.StartIndex, options.TextType, options.Backwards);
+ if (results != null)
+ return results;
+ }
+
+ /* Text not found */
+ return null;
+ }
+
+ /// <summary>Searches backward for text using the specified search options.</summary>
+ /// <param name="options">The search options.</param>
+ /// <returns>The search results, or null in case no results were found.</returns>
+ private SubtitleSearchResults FindBackward (SubtitleSearchOptions options) {
+ SubtitleCollection collection = subtitles.Collection;
+
+ if (collection.Count == 0)
+ return null;
+
+ /* Search the subtitle starting at the startIndex */
+ SubtitleSearchResults results = FindInSubtitleFromIndex(options.StartSubtitle, options.LineBreak, options.Regex, options.StartIndex, options.TextType, options.Backwards);
+ if (results != null)
+ return results;
+
+ /* Iterate through the start of the collection */
+ for (int subtitleNumber = options.StartSubtitle - 1 ; subtitleNumber > 0 ; subtitleNumber--) {
+ results = FindInSubtitle(subtitleNumber, options.LineBreak, options.Regex, options.Backwards);
+ if (results != null)
+ return results;
+ }
+
+ if (options.Wrap) {
+ /* Iterate from the end back to the subtitle */
+ for (int subtitleNumber = collection.Count - 1 ; subtitleNumber > options.StartSubtitle ; subtitleNumber--) {
+ results = FindInSubtitle(subtitleNumber, options.LineBreak, options.Regex, options.Backwards);
+ if (results != null)
+ return results;
+ }
+ /* Search the subtitle ending at the startIndex */
+ results = FindInSubtitleTillIndex(options.StartSubtitle, options.LineBreak, options.Regex, options.StartIndex, options.TextType, options.Backwards);
+ if (results != null)
+ return results;
+ }
+
+ /* Text not found */
+ return null;
+ }
+
+ /// <returns>The <see cref="SubtitleSearchResults" />, or null if the text was not found.</returns>
+ private SubtitleSearchResults FindInSubtitle (int subtitleNumber, string lineBreak, Regex regex, bool backwards) {
+ if (backwards) {
+ /* Find first in the translation */
+ SubtitleSearchResults results = FindInTextContent(subtitleNumber, lineBreak, regex, SubtitleTextType.Translation);
+ if (results != null)
+ return results;
+
+ /* Not found in the translation, finding in the text */
+ return FindInTextContent(subtitleNumber, lineBreak, regex, SubtitleTextType.Text);
+ }
+ else {
+ /* Find first in the text */
+ SubtitleSearchResults results = FindInTextContent(subtitleNumber, lineBreak, regex, SubtitleTextType.Text);
+ if (results != null)
+ return results;
+
+ /* Not found in the text, finding in the translation */
+ return FindInTextContent(subtitleNumber, lineBreak, regex, SubtitleTextType.Translation);
+ }
+ }
+
+ /// <returns>The <see cref="SubtitleSearchResults" />, or null if the text was not found.</returns>
+ private SubtitleSearchResults FindInSubtitleFromIndex (int subtitleNumber, string lineBreak, Regex regex, int startIndex, SubtitleTextType textType, bool backwards) {
+ if (backwards) {
+ if (textType == SubtitleTextType.Text) {
+ /* Find in the text starting at the specified index */
+ return FindInTextContentFromIndex(subtitleNumber, lineBreak, regex, startIndex, SubtitleTextType.Text);
+ }
+ else {
+ /* Find first in the translation starting at the specified index */
+ SubtitleSearchResults results = FindInTextContentFromIndex(subtitleNumber, lineBreak, regex, startIndex, SubtitleTextType.Translation);
+ if (results != null)
+ return results;
+
+ /* Not found in the translation, finding in the text */
+ return FindInTextContent(subtitleNumber, lineBreak, regex, SubtitleTextType.Text);
+ }
+ }
+ else {
+ if (textType == SubtitleTextType.Text) {
+ /* Find first in the text starting at the specified index */
+ SubtitleSearchResults results = FindInTextContentFromIndex(subtitleNumber, lineBreak, regex, startIndex, SubtitleTextType.Text);
+ if (results != null)
+ return results;
+
+ /* Not found in the text, finding in the translation */
+ return FindInTextContent(subtitleNumber, lineBreak, regex, SubtitleTextType.Translation);
+ }
+ else {
+ /* Find in the translation starting at the specified index */
+ return FindInTextContentFromIndex(subtitleNumber, lineBreak, regex, startIndex, SubtitleTextType.Translation);
+ }
+ }
+ }
+
+ /// <returns>The <see cref="SubtitleSearchResults" />, or null if the text was not found.</returns>
+ private SubtitleSearchResults FindInSubtitleTillIndex (int subtitleNumber, string lineBreak, Regex regex, int endIndex, SubtitleTextType textType, bool backwards) {
+ if (backwards) {
+ if (textType == SubtitleTextType.Text) {
+ /* Find first in the translation */
+ SubtitleSearchResults results = FindInTextContent(subtitleNumber, lineBreak, regex, SubtitleTextType.Translation);
+ if (results != null)
+ return results;
+
+ /* Not found in the text, finding in the text till the specified index */
+ return FindInTextContentTillIndex(subtitleNumber, lineBreak, regex, endIndex, SubtitleTextType.Text, backwards);
+ }
+ else {
+ /* Find in the translation till specified index */
+ return FindInTextContentTillIndex(subtitleNumber, lineBreak, regex, endIndex, SubtitleTextType.Translation, backwards);
+ }
+ }
+ else {
+ if (textType == SubtitleTextType.Text) {
+ /* Find in the text ending at the specified index */
+ return FindInTextContentTillIndex(subtitleNumber, lineBreak, regex, endIndex, SubtitleTextType.Text, backwards);
+ }
+ else {
+ /* Find first in the text */
+ SubtitleSearchResults results = FindInTextContent(subtitleNumber, lineBreak, regex, SubtitleTextType.Text);
+ if (results != null)
+ return results;
+
+ /* Not found in the text, finding in the translation till the specified index */
+ return FindInTextContentTillIndex(subtitleNumber, lineBreak, regex, endIndex, SubtitleTextType.Translation, backwards);
+ }
+ }
+ }
+
+ private SubtitleSearchResults FindInTextContent (int subtitleNumber, string lineBreak, Regex regex, SubtitleTextType textType) {
+ SubtitleText text = subtitles.GetSubtitleText(subtitleNumber, textType);
+ return MatchValues(regex.Match(text.Get(lineBreak)), subtitleNumber, textType);
+ }
+
+ private SubtitleSearchResults FindInTextContentFromIndex (int subtitleNumber, string lineBreak, Regex regex, int startIndex, SubtitleTextType textType) {
+ SubtitleText text = subtitles.GetSubtitleText(subtitleNumber, textType);
+ return MatchValues(regex.Match(text.Get(lineBreak), startIndex), subtitleNumber, textType);
+ }
+
+ private SubtitleSearchResults FindInTextContentTillIndex (int subtitleNumber, string lineBreak, Regex regex, int endIndex, SubtitleTextType textType, bool backwards) {
+ SubtitleText text = subtitles.GetSubtitleText(subtitleNumber, textType);
+ string matchText = text.Get(lineBreak);
+ int startIndex = (backwards ? matchText.Length : 0);
+ int length = (backwards ? matchText.Length - endIndex : endIndex);
+ return MatchValues(regex.Match(text.Get(lineBreak), startIndex, length), subtitleNumber, textType);
+ }
+
+ private SubtitleSearchResults MatchValues (Match match, int subtitleNumber, SubtitleTextType textType) {
+ if (match.Success)
+ return new SubtitleSearchResults(subtitleNumber, textType, match.Index, match.Length);
+ else
+ return null;
+ }
+
+
+}
+
+}
diff --git a/src/SubLib/Core/Search/SubtitleSearchOptions.cs b/src/SubLib/Core/Search/SubtitleSearchOptions.cs
new file mode 100644
index 0000000..cb01dbb
--- /dev/null
+++ b/src/SubLib/Core/Search/SubtitleSearchOptions.cs
@@ -0,0 +1,109 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.Core.Search {
+
+/// <summary>Represents the options used during a search operation.</summary>
+public class SubtitleSearchOptions {
+ private Regex regex = null;
+ private string lineBreak = String.Empty;
+ private SubtitleTextType textType = SubtitleTextType.Text;
+ private int startSubtitle = 0;
+ private int startIndex = 0;
+ private bool wrap = false;
+ private bool backwards = false;
+
+ /// <summary>Creates a new instance of the <see cref="SubtitleSearchOptions" /> class.</summary>
+ /// <param name="regex">The regular expression to use when searching. It must be created with
+ /// <see cref="RegexOptions.IgnoreCase" /> to perform a case-insensitive search.</param>
+ /// <param name="textType">The type of text content the search is started at.</param>
+ /// <param name="lineBreak">The line break to use between multiple lines of text in each subtitle.</param>
+ /// <param name="startSubtitle">The zero-based number of the subtitle to start the search at.</param>
+ /// <param name="startIndex">The zero-based position within the startSubtitle to start the search at.</param>
+ /// <param name="wrap">Whether to continue the search from the beginning when it reaches the end of the subtitles.</param>
+ /// <param name="backwards">Whether to search backwards. Note that regex must be constructed with the
+ /// <see cref="RegexOptions.RightToLeft" /> option for backwards search to work.</param>
+ public SubtitleSearchOptions (Regex regex, SubtitleTextType textType, string lineBreak, int startSubtitle, int startIndex, bool wrap, bool backwards) {
+ this.regex = regex;
+ this.textType = textType;
+ this.lineBreak = lineBreak;
+ this.startSubtitle = startSubtitle;
+ this.startIndex = startIndex;
+ this.wrap = wrap;
+ this.backwards = backwards;
+ }
+
+ /// <summary>Creates a new instance of the <see cref="SubtitleSearchOptions" /> class.</summary>
+ /// <param name="regex">The regular expression to use when searching. It must be created with
+ /// <see cref="RegexOptions.IgnoreCase" /> to perform a case-insensitive search.</param>
+ /// <param name="textType">The type of text content the search is started at.</param>
+ /// <param name="startSubtitle">The zero-based number of the subtitle to start the search at.</param>
+ /// <param name="startIndex">The zero-based position within the startSubtitle to start the search at.</param>
+ /// <param name="wrap">Whether to continue the search from the beginning when it reaches the end of the subtitles.</param>
+ /// <param name="backwards">Whether to search backwards. Note that regex must be constructed with the
+ /// <see cref="RegexOptions.RightToLeft" /> option for backwards search to work.</param>
+ /// <remarks>The newline character (\n) is used as lineBreak.</remarks>
+ public SubtitleSearchOptions (Regex regex, SubtitleTextType textType, int startSubtitle, int startIndex, bool wrap, bool backwards)
+ : this(regex, textType, "\n", startSubtitle, startIndex, wrap, backwards) {
+ }
+
+ /* Public properties */
+
+ /// <summary>The regular expression.</summary>
+ public Regex Regex {
+ get { return regex; }
+ }
+
+ /// <summary>The linebreak used to use between multiple lines of text.</summary>
+ public string LineBreak {
+ get { return lineBreak; }
+ }
+
+ /// <summary>The type of text content to start the search with.</summary>
+ public SubtitleTextType TextType {
+ get { return textType; }
+ }
+
+ /// <summary>The subtitle to start the search with.</summary>
+ public int StartSubtitle {
+ get { return startSubtitle; }
+ }
+
+ /// <summary>The index of the text to start the search with.</summary>
+ public int StartIndex {
+ get { return startIndex; }
+ }
+
+ /// <summary>Whether to continue the search from the beginning when it reaches the end of the subtitles.</summary>
+ public bool Wrap {
+ get { return wrap; }
+ }
+
+ /// <summary>Whether to search backwards.</summary>
+ public bool Backwards {
+ get { return backwards; }
+ }
+
+}
+
+}
diff --git a/src/SubLib/Core/Search/SubtitleSearchResults.cs b/src/SubLib/Core/Search/SubtitleSearchResults.cs
new file mode 100644
index 0000000..debb178
--- /dev/null
+++ b/src/SubLib/Core/Search/SubtitleSearchResults.cs
@@ -0,0 +1,68 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+
+namespace SubLib.Core.Search {
+
+/// <summary>Represents the results of a search operation.</summary>
+public class SubtitleSearchResults {
+ private int subtitle = -1;
+ private SubtitleTextType textType = SubtitleTextType.Text;
+ private int index = -1;
+ private int length = -1;
+
+ /// <summary>Creates a new instance of the <see cref="SubtitleSearchResults" /> class.</summary>
+ /// <param name="subtitle">The zero-based number of the subtitle where the text was found.</param>
+ /// <param name="textType">The type of text content where the text was found.</param>
+ /// <param name="index">The zero-based position where the text was found, within a subtitle.</param>
+ /// <param name="length">The length of the found text.</param>
+ public SubtitleSearchResults (int subtitle, SubtitleTextType textType, int index, int length) {
+ this.subtitle = subtitle;
+ this.textType = textType;
+ this.index = index;
+ this.length = length;
+ }
+
+ /* Public properties */
+
+ /// <summary>The subtitle number.</summary>
+ public int Subtitle {
+ get { return subtitle; }
+ }
+
+ /// <summary>The type of the text content.</summary>
+ public SubtitleTextType TextType {
+ get { return textType; }
+ }
+
+ /// <summary>The text index.</summary>
+ public int Index {
+ get { return index; }
+ }
+
+ /// <summary>The text length.</summary>
+ public int Length {
+ get { return length; }
+ }
+
+}
+
+}
diff --git a/src/SubLib/Core/SubtitleFactory.cs b/src/SubLib/Core/SubtitleFactory.cs
new file mode 100644
index 0000000..d9edfa8
--- /dev/null
+++ b/src/SubLib/Core/SubtitleFactory.cs
@@ -0,0 +1,213 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using SubLib.IO.SubtitleFormats;
+using SubLib.IO.Input;
+using SubLib.IO.Output;
+using System;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace SubLib.Core {
+
+/// <summary>Represents the main mechanism for creating new <see cref="Subtitles" />.</summary>
+/// <remarks>A <see cref="SubtitleFactory" /> is no longer needed after the subtitles have been created.</remarks>
+public class SubtitleFactory {
+ private IncompleteSubtitleCollection incompleteSubtitles = null;
+ private FileProperties fileProperties = null;
+
+ private bool includeIncompleteSubtitles = false;
+
+ private Encoding encoding = null; //The encoding to be used to open a file
+ private Encoding fallbackEncoding = Encoding.GetEncoding(1252); //The encoding to fall back to when no encoding is detected
+
+ private SubtitleType subtitleType = SubtitleType.Unknown;
+
+ /// <summary>The incomplete subtitles that were found when opening a file.</summary>
+ /// <remarks>This is only used when <see cref="IncludeIncompleteSubtitles" /> is set.</remarks>
+ public IncompleteSubtitleCollection IncompleteSubtitles {
+ get { return incompleteSubtitles; }
+ }
+
+ /// <summary>The properties of an opened file, after opening.</summary>
+ public FileProperties FileProperties {
+ get { return fileProperties; }
+ }
+
+ /// <summary>Whether to enable the library to print messages to the console.</summary>
+ /// <remarks>Messages will be shown along with the main methods of <see cref="SubtitleFactory" />
+ /// and <see cref="Subtitles" />. The default value is false.</remarks>
+ public bool Verbose {
+ get { return VerboseConsole.Verbose; }
+ set { VerboseConsole.Verbose = value; }
+ }
+
+ /// <summary>Whether to detect and store incomplete subtitles found upon open.</summary>
+ /// <remarks>The default value is false.</remarks>
+ public bool IncludeIncompleteSubtitles {
+ get { return includeIncompleteSubtitles; }
+ set { includeIncompleteSubtitles = value; }
+ }
+
+ /// <summary>The encoding to be used upon open.</summary>
+ /// <remarks>When set to null, encoding auto-detection is used. The default value is null (use auto-detection).</remarks>
+ public Encoding Encoding {
+ get { return encoding; }
+ set { encoding = value; }
+ }
+
+ /// <summary>The encoding to fallback to when using encoding auto-detection.</summary>
+ /// <remarks>When using encoding auto-detection, this encoding will be used if no encoding could be auto-detected.
+ /// Defaults to Windows-1252.</remarks>
+ public Encoding FallbackEncoding {
+ get { return fallbackEncoding; }
+ set { fallbackEncoding = value; }
+ }
+
+ /// <summary>The type of the subtitle being opened.</summary>
+ /// <remarks>When set to <see cref="SubtitleType.Unknown" />, subtitle type auto-detection is used.
+ /// The default value is <see cref="SubtitleType.Unknown" /> (auto-detection).</remarks>
+ public SubtitleType SubtitleType {
+ get { return subtitleType; }
+ set { subtitleType = value; }
+ }
+
+ /// <summary>Creates new empty <see cref="Subtitles" />.</summary>
+ /// <returns>The newly created subtitles.</returns>
+ public Subtitles New () {
+ SubtitleCollection collection = new SubtitleCollection();
+ SubtitleProperties properties = new SubtitleProperties();
+ return new Subtitles(collection, properties);
+ }
+
+ /// <summary>Creates <see cref="Subtitles" /> by opening the file at the specified path.</summary>
+ /// <remarks>The properties of the opened file are accessible with <see cref="FileProperties" />, after opening.</remarks>
+ /// <returns>The opened subtitles.</returns>
+ /// <exception cref="EncodingNotSupportedException">Thrown if a detected encoding is not supported by the platform.</exception>
+ /// <exception cref="UnknownSubtitleFormatException">Thrown if a subtitle format could not be detected.</exception>
+ public Subtitles Open (string path){
+ SubtitleFormat format = null;
+ string text = String.Empty;
+ Encoding fileEncoding = null;
+
+ SubtitleInput input = new SubtitleInput(fallbackEncoding, subtitleType);
+ if (encoding == null) {
+ text = input.Read(path, out fileEncoding, out format);
+ }
+ else {
+ text = input.Read(path, encoding, out format);
+ fileEncoding = encoding;
+ }
+
+ if (IsTextEmpty(text))
+ return EmptySubtitles(path);
+ else
+ return ParsedSubtitles(path, fileEncoding, format, text);
+ }
+
+ /// <summary>Creates <see cref="Subtitles" /> by opening the plain text file at the specified path.</summary>
+ /// <remarks>The properties of the opened file are accessible with <see cref="FileProperties" />, after opening.</remarks>
+ /// <returns>The opened lines turned into subtitles.</returns>
+ /// <exception cref="EncodingNotSupportedException">Thrown if a detected encoding is not supported by the platform.</exception>
+ /// <exception cref="UnknownSubtitleFormatException">Thrown if a subtitle format could not be detected.</exception>
+ public Subtitles OpenPlain (string path, bool withCharacterNames,
+ TimingMode timingMode,
+ string lineSeparator) {
+ string text = String.Empty;
+ Encoding fileEncoding = null;
+
+ SubtitleInput input = new SubtitleInput(fallbackEncoding, subtitleType);
+ if (encoding == null) {
+ text = input.ReadPlain(path, out fileEncoding);
+ }
+ else {
+ text = input.ReadPlain(path, encoding);
+ fileEncoding = encoding;
+ }
+ if (IsTextEmpty(text))
+ return EmptySubtitles(path);
+ else
+ return ParsedSubtitlesPlain(path, fileEncoding, text, withCharacterNames,
+ timingMode, lineSeparator);
+ }
+
+ /* Private members */
+
+ private Subtitles ParsedSubtitles (string path, Encoding fileEncoding, SubtitleFormat format, string text) {
+ SubtitleCollection collection = null;
+ SubtitleParser subtitleParser = new SubtitleParser(includeIncompleteSubtitles);
+ ParsingProperties parsingProperties = subtitleParser.Parse(text, format, out collection, out incompleteSubtitles);
+
+ SubtitleProperties subtitleProperties = new SubtitleProperties(parsingProperties);
+ collection.SetPropertiesForAll(subtitleProperties);
+
+ Subtitles subtitles = new Subtitles(collection, subtitleProperties);
+ CompleteTimingsAfterParsing(subtitles, parsingProperties);
+
+ fileProperties = new FileProperties(path, fileEncoding, format.Type , parsingProperties.TimingMode);
+
+ VerboseConsole.WriteLine("[*] opened " + path + " with encoding " + fileEncoding + " and format " + format.Name);
+ return subtitles;
+ }
+
+ private Subtitles ParsedSubtitlesPlain (string path, Encoding fileEncoding, string text, bool withCharacterNames,
+ TimingMode timingMode, string lineSeparator) {
+ SubtitleCollection collection = null;
+ PlainTextParser plainParser = new PlainTextParser(withCharacterNames, lineSeparator);
+ ParsingProperties parsingProperties = plainParser.Parse(text, timingMode, fileEncoding, out collection);
+
+ SubtitleProperties subtitleProperties = new SubtitleProperties(parsingProperties);
+ collection.SetPropertiesForAll(subtitleProperties);
+
+ Subtitles subtitles = new Subtitles(collection, subtitleProperties);
+ CompleteTimingsAfterParsing(subtitles, parsingProperties);
+
+ fileProperties = new FileProperties(path, fileEncoding, parsingProperties.TimingMode);
+
+ VerboseConsole.WriteLine("[*] opened " + path + " with encoding " + fileEncoding);
+ return subtitles;
+ }
+
+ private Subtitles EmptySubtitles (string path) {
+ Subtitles subtitles = New();
+ fileProperties = new FileProperties(path, Encoding.UTF8, SubtitleType.Unknown, TimingMode.Times);
+ return subtitles;
+ }
+
+ private bool IsTextEmpty (string text) {
+ Regex regex = new Regex(@"\s*");
+ Match match = regex.Match(text);
+ return (match.Length == text.Length);
+ }
+
+ private void CompleteTimingsAfterParsing(Subtitles subtitles, ParsingProperties parsingProperties){
+ float originalFrameRate = subtitles.Properties.OriginalFrameRate;
+ subtitles.Properties.SetCurrentFrameRate(originalFrameRate);
+
+ if (parsingProperties.TimingMode == TimingMode.Times)
+ subtitles.UpdateFramesFromTimes(originalFrameRate);
+ else
+ subtitles.UpdateTimesFromFrames(originalFrameRate);
+ }
+
+}
+
+}
+
diff --git a/src/SubLib/Core/SubtitleSaver.cs b/src/SubLib/Core/SubtitleSaver.cs
new file mode 100644
index 0000000..c9a6531
--- /dev/null
+++ b/src/SubLib/Core/SubtitleSaver.cs
@@ -0,0 +1,71 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using SubLib.IO;
+using SubLib.IO.Output;
+using SubLib.IO.SubtitleFormats;
+
+namespace SubLib.Core {
+
+/// <summary>Represents the main mechanism for saving <see cref="Subtitles" />.</summary>
+public class SubtitleSaver {
+ private FileProperties fileProperties = null;
+
+
+ /* Public properties */
+
+ /// <summary>The new properties of the file after saving.</summary>
+ /// <remarks>This includes the updated <see cref="TimingMode" /> for the subtitles after saving. When saving to
+ /// a subtitle format that supports only time or frame timing modes, this is updated to reflect that.</remarks>
+ public FileProperties FileProperties {
+ get { return fileProperties; }
+ }
+
+ /* Public methods */
+
+ /// <summary>Saves subtitles to the file with the specified properties.</summary>
+ /// <param name="subtitles">The subtitles to save.</param>
+ /// <param name="properties">The properties of the file to save the subtitles to. Its <see cref="TimingMode" /> property is used to
+ /// choose the timing mode for subtitle formats that support both time and frame modes.</param>
+ /// <param name="textType">The type of text content to save.</param>
+ /// <remarks>An updated <see cref="SubLib.FileProperties" /> object can be accessed with <see cref="FileProperties" /> after saving.</remarks>
+ public void Save (Subtitles subtitles, FileProperties properties, SubtitleTextType textType) {
+ SubtitleFormat format = BuiltInSubtitleFormats.GetFormat(properties.SubtitleType);
+ SubtitleOutput output = new SubtitleOutput(format, textType);
+
+ string text = output.Build(subtitles.Collection, subtitles.Properties, properties);
+ FileInputOutput.WriteFile(properties.Path, text, properties.Encoding);
+
+
+ fileProperties = GetUpdatedFileProperties(properties);
+ VerboseConsole.WriteLine("[*] Saved " + textType + " " + properties.Path + " with encoding " + properties.Encoding + " and format " + format.Name);
+ }
+
+ /* Private methods */
+
+ private FileProperties GetUpdatedFileProperties (FileProperties properties) {
+ SubtitleFormat format = BuiltInSubtitleFormats.GetFormat(properties.SubtitleType);
+ TimingMode newTimingMode = (format.Mode == SubtitleMode.Both) ? properties.TimingMode : format.ModeAsTimingMode;
+
+ return new FileProperties(properties.Path, properties.Encoding, properties.SubtitleType, newTimingMode, properties.NewlineType);
+ }
+}
+
+}
\ No newline at end of file
diff --git a/src/SubLib/Core/Timing/AdjustOperator.cs b/src/SubLib/Core/Timing/AdjustOperator.cs
new file mode 100644
index 0000000..088b124
--- /dev/null
+++ b/src/SubLib/Core/Timing/AdjustOperator.cs
@@ -0,0 +1,85 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2006-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+
+namespace SubLib.Core.Timing {
+
+/// <summary>Performs adjustment operations.</summary>
+public class AdjustOperator {
+ private Subtitles subtitles = null;
+
+ public AdjustOperator (Subtitles subtitles) {
+ this.subtitles = subtitles;
+ }
+
+ /* Public members */
+
+ /// <summary>Auto adjusts the subtitles given the correct times for the first and last subtitle.</summary>
+ /// <remarks>The subtitles are first shifted to the first subtitle's correct time, and then proportionally
+ /// adjusted using the last subtitle's correct time.</remarks>
+ /// <param name="startTime">The correct start time for the first subtitle.</param>
+ /// <param name="endTime">The correct start time for the last subtitle.</param>
+ /// <returns>Whether the subtitles could be adjusted.</returns>
+ public bool Adjust (TimeSpan startTime, TimeSpan endTime) {
+ int startIndex = 0;
+ int endIndex = subtitles.Collection.Count - 1;
+ return Adjust(startIndex, startTime, endIndex, endTime);
+ }
+
+ /// <summary>Auto adjusts a range of subtitles given their first and last correct times.</summary>
+ /// <remarks>The subtitles are first shifted to the first subtitle's correct time, and then proportionally
+ /// adjusted using the last subtitle's correct time.</remarks>
+ /// <param name="startIndex">The subtitle index to start the adjustment with.</param>
+ /// <param name="startTime">The correct start time for the first subtitle.</param>
+ /// <param name="endIndex">The subtitle index to end the adjustment with.</param>
+ /// <param name="endTime">The correct start time for the last subtitle.</param>
+ /// <returns>Whether the subtitles could be adjusted.</returns>
+ public bool Adjust (int startIndex, TimeSpan startTime, int endIndex, TimeSpan endTime) {
+ return SyncUtil.Sync(subtitles, startIndex, startTime, endIndex, endTime);
+ }
+
+ /// <summary>Auto adjusts the subtitles given the correct frames for the first and last subtitle.</summary>
+ /// <remarks>The subtitles are first shifted to the first subtitle's correct frame, and then proportionally
+ /// adjusted using the last subtitle's correct frame.</remarks>
+ /// <param name="startFrame">The correct start frame for the first subtitle.</param>
+ /// <param name="endFrame">The correct start frame for the last subtitle.</param>
+ /// <returns>Whether the subtitles could be adjusted.</returns>
+ public bool Adjust (int startFrame, int endFrame) {
+ int startIndex = 0;
+ int endIndex = subtitles.Collection.Count - 1;
+ return Adjust(startIndex, startFrame, endIndex, endFrame);
+ }
+
+ /// <summary>Auto adjusts a range of subtitles given their first and last correct frames.</summary>
+ /// <remarks>The subtitles are first shifted to the first subtitle's correct frame, and then proportionally
+ /// adjusted using the last subtitle's correct frame.</remarks>
+ /// <param name="startIndex">The subtitle index to start the adjustment with.</param>
+ /// <param name="startFrame">The correct start frame for the first subtitle.</param>
+ /// <param name="endIndex">The subtitle index to end the adjustment with.</param>
+ /// <param name="endFrame">The correct start frame for the last subtitle.</param>
+ /// <returns>Whether the subtitles could be adjusted.</returns>
+ public bool Adjust (int startIndex, int startFrame, int endIndex, int endFrame) {
+ return SyncUtil.Sync(subtitles, startIndex, startFrame, endIndex, endFrame);
+ }
+
+}
+
+}
diff --git a/src/SubLib/Core/Timing/FrameRateOperator.cs b/src/SubLib/Core/Timing/FrameRateOperator.cs
new file mode 100644
index 0000000..590676b
--- /dev/null
+++ b/src/SubLib/Core/Timing/FrameRateOperator.cs
@@ -0,0 +1,67 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2006-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+
+namespace SubLib.Core.Timing {
+
+/// <summary>Performs frame rate operations.</summary>
+public class FrameRateOperator {
+ private Subtitles subtitles = null;
+
+ public FrameRateOperator (Subtitles subtitles) {
+ this.subtitles = subtitles;
+ }
+
+ /* Public members */
+
+
+ /// <summary>Changes the current frame rate of the subtitles.</summary>
+ /// <param name="frameRate">The new frame rate to be used.</param>
+ /// <remarks>This changes the frame rate currently being used with the subtitles, which is sometimes
+ /// refered to as the output frame rate.</remarks>
+ public void ChangeCurrent (float frameRate) {
+ float currentFrameRate = subtitles.Properties.CurrentFrameRate;
+ if (currentFrameRate != frameRate) {
+ subtitles.Properties.SetCurrentFrameRate(frameRate);
+ subtitles.UpdateFramesFromTimes(frameRate);
+ }
+ }
+
+ /// <summary>Updates the subtitles' frames using the specified frame rate as the one they had when they were opened.</summary>
+ /// <param name="frameRate">The original subtitles' frame rate.</param>
+ /// <remarks>This results on having the subtitles with the frames they would have if they had been opened with this frame rate.
+ /// The original frame rate is sometimes refered to as the input frame rate.</remarks>
+ public void ChangeOriginal (float frameRate) {
+ SubtitleProperties properties = subtitles.Properties;
+ float originalFrameRate = properties.OriginalFrameRate;
+ float currentFrameRate = properties.CurrentFrameRate;
+
+ if (originalFrameRate != frameRate) {
+ float conversionFrameRate = currentFrameRate * originalFrameRate / frameRate;
+ subtitles.UpdateFramesFromTimes(conversionFrameRate);
+ subtitles.UpdateTimesFromFrames(currentFrameRate);
+ properties.SetOriginalFrameRate(frameRate);
+ }
+ }
+
+}
+
+}
diff --git a/src/SubLib/Core/Timing/ShiftOperator.cs b/src/SubLib/Core/Timing/ShiftOperator.cs
new file mode 100644
index 0000000..bef5b17
--- /dev/null
+++ b/src/SubLib/Core/Timing/ShiftOperator.cs
@@ -0,0 +1,96 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2006-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+
+namespace SubLib.Core.Timing {
+
+/// <summary>Performs shift operations.</summary>
+public class ShiftOperator {
+ private Subtitles subtitles = null;
+
+ public ShiftOperator (Subtitles subtitles) {
+ this.subtitles = subtitles;
+ }
+
+ /* Public members */
+
+ /// <summary>Shifts the subtitles a specified amount of time.</summary>
+ /// <param name="time">The time to use, which can be positive or negative.</param>
+ public void Shift (TimeSpan time) {
+ foreach (Subtitle subtitle in subtitles.Collection)
+ subtitle.Times.Shift(time);
+ }
+
+ /// <summary>Shifts a range of subtitles a specified amount of time.</summary>
+ /// <param name="time">The time to use, which can be positive or negative.</param>
+ /// <param name="startIndex">The subtitle index the range begins with.</param>
+ /// <param name="endIndex">The subtitle index the range ends with.</param>
+ public void Shift (TimeSpan time, int startIndex, int endIndex) {
+ if (!AreShiftArgsValid(startIndex, endIndex))
+ return;
+
+ for (int index = startIndex ; index <= endIndex ; index++) {
+ Subtitle subtitle = subtitles.Collection.Get(index);
+ subtitle.Times.Shift(time);
+ }
+ }
+
+ /// <summary>Shifts the subtitles a specified amount of frames.</summary>
+ /// <param name="frames">The frames to use, which can be positive or negative.</param>
+ public void Shift (int frames) {
+ foreach (Subtitle subtitle in subtitles.Collection)
+ subtitle.Frames.Shift(frames);
+ }
+
+ /// <summary>Shifts a range of subtitles a specified amount of frames.</summary>
+ /// <param name="frames">The frames to use, which can be positive or negative.</param>
+ /// <param name="startIndex">The subtitle index the range begins with.</param>
+ /// <param name="endIndex">The subtitle index the range ends with.</param>
+ public void Shift (int frames, int startIndex, int endIndex) {
+ if (!AreShiftArgsValid(startIndex, endIndex))
+ return;
+
+ for (int index = startIndex ; index <= endIndex ; index++) {
+ Subtitle subtitle = subtitles.Collection.Get(index);
+ subtitle.Frames.Shift(frames);
+ }
+ }
+
+
+ /* Private members */
+
+ private bool AreShiftArgsValid (int startIndex, int endIndex) {
+ int subtitleCount = subtitles.Collection.Count;
+ if (subtitleCount == 0)
+ return false;
+ else if (!(startIndex <= endIndex))
+ return false;
+ else if ((startIndex < 0) || (startIndex >= subtitleCount))
+ return false;
+ else if (endIndex >= subtitleCount)
+ return false;
+ else
+ return true;
+ }
+
+}
+
+}
diff --git a/src/SubLib/Core/Timing/SyncUtil.cs b/src/SubLib/Core/Timing/SyncUtil.cs
new file mode 100644
index 0000000..05152ec
--- /dev/null
+++ b/src/SubLib/Core/Timing/SyncUtil.cs
@@ -0,0 +1,134 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2009 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+
+namespace SubLib.Core.Timing {
+
+public class SyncUtil {
+
+ public static bool Sync (Subtitles subtitles, SyncPoint start, SyncPoint end) {
+ return Sync(subtitles, start.SubtitleNumber, start.Correct.Time, end.SubtitleNumber, end.Correct.Time);
+ }
+
+ /// <summary>Auto syncs a range of subtitles given their first and last correct times.</summary>
+ /// <remarks>The subtitles are first shifted to the first subtitle's correct time, and then proportionally
+ /// adjusted using the last subtitle's correct time.</remarks>
+ /// <param name="subtitles">The subtitles to sync.</param>
+ /// <param name="startIndex">The subtitle index to start the adjustment with.</param>
+ /// <param name="startTime">The correct start time for the first subtitle.</param>
+ /// <param name="endIndex">The subtitle index to end the adjustment with.</param>
+ /// <param name="endTime">The correct start time for the last subtitle.</param>
+ /// <returns>Whether the subtitles could be adjusted.</returns>
+ public static bool Sync (Subtitles subtitles, int startIndex, TimeSpan startTime, int endIndex, TimeSpan endTime) {
+ if (!AreSyncArgsValid(subtitles, startIndex, startTime, endIndex, endTime))
+ return false;
+
+ /* Shift subtitles to the start point */
+ Subtitle startSubtitle = subtitles.Collection.Get(startIndex);
+ TimeSpan shift = startTime - startSubtitle.Times.PreciseStart;
+ if (shift != TimeSpan.Zero) {
+ ShiftOperator shiftOp = new ShiftOperator(subtitles);
+ shiftOp.Shift(shift, startIndex, endIndex);
+ }
+
+ /* Auto adjust timings with proportion */
+ Subtitle endSubtitle = subtitles.Collection.Get(endIndex);
+ double factor = (endTime - startTime).TotalMilliseconds / (endSubtitle.Times.PreciseStart - startTime).TotalMilliseconds;
+ for (int index = startIndex ; index <= endIndex ; index++) {
+ Subtitle subtitle = subtitles.Collection.Get(index);
+ subtitle.Times.Scale(factor, startTime);
+ }
+ return true;
+ }
+
+ /// <summary>Auto syncs a range of subtitles given their first and last correct frames.</summary>
+ /// <remarks>The subtitles are first shifted to the first subtitle's correct frame, and then proportionally
+ /// adjusted using the last subtitle's correct frame.</remarks>
+ /// <param name="subtitles">The subtitles to sync.</param>
+ /// <param name="startIndex">The subtitle index to start the adjustment with.</param>
+ /// <param name="startFrame">The correct start frame for the first subtitle.</param>
+ /// <param name="endIndex">The subtitle index to end the adjustment with.</param>
+ /// <param name="endFrame">The correct start frame for the last subtitle.</param>
+ /// <returns>Whether the subtitles could be adjusted.</returns>
+ public static bool Sync (Subtitles subtitles, int startIndex, int startFrame, int endIndex, int endFrame) {
+ if (!AreSyncArgsValid(subtitles, startIndex, startFrame, endIndex, endFrame))
+ return false;
+
+ /* Shift subtitles to the start point */
+ Subtitle startSubtitle = subtitles.Collection.Get(startIndex);
+ int shift = (int)(startFrame - startSubtitle.Frames.PreciseStart);
+ if (shift != 0) {
+ ShiftOperator shiftOp = new ShiftOperator(subtitles);
+ shiftOp.Shift(shift, startIndex, endIndex);
+ }
+
+ /* Auto adjust timings with proportion */
+ Subtitle endSubtitle = subtitles.Collection.Get(endIndex);
+ double factor = (endFrame - startFrame) / (endSubtitle.Frames.PreciseStart - startFrame);
+ for (int index = startIndex ; index <= endIndex ; index++) {
+ Subtitle subtitle = subtitles.Collection.Get(index);
+ subtitle.Frames.Scale(factor, startFrame);
+ }
+ return true;
+ }
+
+ /* Private members */
+
+ public static bool AreSyncPointsValid (Subtitles subtitles, SyncPoint start, SyncPoint end) {
+ return AreSyncArgsValid(subtitles, start.SubtitleNumber, start.Correct.Time, end.SubtitleNumber, end.Correct.Time)
+ && AreSyncArgsValid(subtitles, start.SubtitleNumber, start.Correct.Frame, end.SubtitleNumber, end.Correct.Frame);
+ }
+
+ private static bool AreSyncArgsValid (Subtitles subtitles, int startIndex, TimeSpan startTime, int endIndex, TimeSpan endTime) {
+ if (!AreSyncIndicesValid(subtitles, startIndex, endIndex))
+ return false;
+ else if (!(startTime < endTime))
+ return false;
+ else
+ return true;
+ }
+
+ private static bool AreSyncArgsValid (Subtitles subtitles, int startIndex, int startTime, int endIndex, int endTime) {
+ if (!AreSyncIndicesValid(subtitles, startIndex, endIndex))
+ return false;
+ else if (!(startTime < endTime))
+ return false;
+ else
+ return true;
+ }
+
+ private static bool AreSyncIndicesValid (Subtitles subtitles, int startIndex, int endIndex) {
+ int subtitleCount = subtitles.Collection.Count;
+ if (subtitleCount < 2)
+ return false;
+ else if (!(startIndex < endIndex))
+ return false;
+ else if ((startIndex < 0) || (startIndex >= (subtitleCount - 1)))
+ return false;
+ else if (endIndex >= subtitleCount)
+ return false;
+ else
+ return true;
+ }
+
+}
+
+}
diff --git a/src/SubLib/Core/Timing/SynchronizeOperator.cs b/src/SubLib/Core/Timing/SynchronizeOperator.cs
new file mode 100644
index 0000000..d1db2ae
--- /dev/null
+++ b/src/SubLib/Core/Timing/SynchronizeOperator.cs
@@ -0,0 +1,101 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2008-2009 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+
+namespace SubLib.Core.Timing {
+
+/// <summary>Performs synchronization operations.</summary>
+public class SynchronizeOperator {
+ private Subtitles subtitles = null;
+
+ public SynchronizeOperator (Subtitles subtitles) {
+ this.subtitles = subtitles;
+ }
+
+ /* Public members */
+
+ public bool Sync (SyncPoints syncPoints, bool toSyncAll) {
+ SyncPoints pointsToUse = AdaptForOperation(syncPoints, toSyncAll);
+ if (!AreSyncArgsValid(pointsToUse))
+ return false;
+
+ System.Console.WriteLine("Here");
+ SyncPoint previous = pointsToUse[0];
+ for (int index = 1 ; index < pointsToUse.Count ; index++) {
+ System.Console.WriteLine(index);
+ SyncPoint current = pointsToUse[index];
+ SyncUtil.Sync(subtitles, previous, current);
+
+ previous = current;
+ }
+
+ return true;
+ }
+
+
+ /* Private members */
+
+ private SyncPoints AdaptForOperation (SyncPoints syncPoints, bool toSyncAll) {
+ if ((syncPoints == null) || (!toSyncAll))
+ return syncPoints;
+
+ SyncPoints adapted = syncPoints.Clone();
+
+ /* Add the first subtitle if possible */
+ int firstSubtitleNumber = 0;
+ if ((subtitles.Collection.Count > 0) && (!adapted.Contains(firstSubtitleNumber))) {
+ Subtitle firstSubtitle = subtitles.Collection[firstSubtitleNumber];
+ Domain.Timing firstSubtitleTiming = new Domain.Timing(firstSubtitle.Frames.Start, firstSubtitle.Times.Start);
+ SyncPoint firstSyncPoint = new SyncPoint(firstSubtitleNumber, firstSubtitleTiming, firstSubtitleTiming);
+ adapted.Add(firstSyncPoint);
+ }
+
+ /* Add last subtitle if possible */
+ int lastSubtitleNumber = subtitles.Collection.Count - 1;
+ if ((subtitles.Collection.Count > 1) && (!adapted.Contains(lastSubtitleNumber))) {
+ Subtitle lastSubtitle = subtitles.Collection[lastSubtitleNumber - 1];
+ Domain.Timing lastSubtitleTiming = new Domain.Timing(lastSubtitle.Frames.Start, lastSubtitle.Times.Start);
+ SyncPoint lastSyncPoint = new SyncPoint(lastSubtitleNumber, lastSubtitleTiming, lastSubtitleTiming);
+ adapted.Add(lastSyncPoint);
+ }
+
+ return adapted;
+ }
+
+ private bool AreSyncArgsValid (SyncPoints syncPoints) {
+ System.Console.WriteLine(1);
+ if ((syncPoints == null) || (syncPoints.Count < 2) || (syncPoints[syncPoints.Count - 1].SubtitleNumber > subtitles.Collection.Count))
+ return false;
+ System.Console.WriteLine(2);
+ SyncPoint previous = syncPoints[0];
+ for (int index = 1 ; index < syncPoints.Count ; index++) {
+ SyncPoint current = syncPoints[index];
+ if (!SyncUtil.AreSyncPointsValid(subtitles, previous, current))
+ return false;
+
+ previous = current;
+ }
+ return true;
+ }
+
+}
+
+}
diff --git a/src/SubLib/Core/Timing/TimingUtil.cs b/src/SubLib/Core/Timing/TimingUtil.cs
new file mode 100644
index 0000000..c449d02
--- /dev/null
+++ b/src/SubLib/Core/Timing/TimingUtil.cs
@@ -0,0 +1,67 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2009 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System;
+
+namespace SubLib.Core.Timing {
+
+/// <summary>Contains utilitary methods for synchronization operations.</summary>
+public class TimingUtil {
+
+ /// <summary>Converts the specified frames to time, given a frame rate.</summary>
+ /// <param name="frames">The frames to convert to time.</param>
+ /// <param name="frameRate">The frame rate to be used in the conversion.</param>
+ /// <returns>The time corresponding to the specified frames at the specified frame rate.</returns>
+ public static TimeSpan FramesToTime (double frames, float frameRate) {
+ double seconds = frames / frameRate;
+ TimeSpan time = TimeSpan.FromSeconds(seconds);
+ return time;
+ }
+
+ /// <summary>Converts the specified time to frames, given a frame rate.</summary>
+ /// <param name="time">The time to convert to frames.</param>
+ /// <param name="frameRate">The frame rate to be used in the conversion.</param>
+ /// <returns>The frames corresponding to the specified time at the specified frame rate.</returns>
+ public static double TimeToFrames (TimeSpan time, float frameRate) {
+ double seconds = time.TotalSeconds;
+ double frames = seconds * frameRate;
+ return frames;
+ }
+
+ /// <summary>Converts the specified time to frames, given a frame rate.</summary>
+ /// <param name="time">The time, in seconds, to convert to frames.</param>
+ /// <param name="frameRate">The frame rate to be used in the conversion.</param>
+ /// <returns>The frames corresponding to the specified time at the specified frame rate.</returns>
+ public static double TimeToFrames (float time, float frameRate) {
+ double frames = time * frameRate;
+ return frames;
+ }
+
+ /// <summary>Converts the specified time to frames, given a frame rate.</summary>
+ /// <param name="time">The time, in milliseconds, to convert to frames.</param>
+ /// <param name="frameRate">The frame rate to be used in the conversion.</param>
+ /// <returns>The frames corresponding to the specified time at the specified frame rate.</returns>
+ public static double TimeMillisecondsToFrames (float time, float frameRate) {
+ double frames = (time / 1000) * frameRate;
+ return frames;
+ }
+
+}
+
+}
diff --git a/src/SubLib/Core/Translations.cs b/src/SubLib/Core/Translations.cs
new file mode 100644
index 0000000..afa5a2c
--- /dev/null
+++ b/src/SubLib/Core/Translations.cs
@@ -0,0 +1,78 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+
+namespace SubLib.Core {
+
+/// <summary>Allows to import translation subtitles into existing subtitles.</summary>
+public class Translations {
+
+ /// <summary>Creates a new instance of the <see cref="Translations" /> class.</summary>
+ public Translations () {
+ }
+
+ /* Public methods */
+
+ //TODO have more elaborate heuristics, taking the times into account and reporting errors
+ /// <summary>Imports translated subtitles into existing subtitles.</summary>
+ /// <param name="subtitles">The subtitles to import the translation to.</param>
+ /// <param name="translation">The translated subtitles.</param>
+ public void Import (Subtitles subtitles, Subtitles translation) {
+ AddExtraSubtitles(subtitles, translation);
+ CopyTranslation(subtitles, translation);
+ }
+
+ /// <summary>Removes the entire translation from existing subtitles.</summary>
+ /// <param name="subtitles">The subtitles to remove the translation from.</param>
+ public void Clear (Subtitles subtitles) {
+ foreach (Subtitle subtitle in subtitles.Collection)
+ subtitle.ClearTranslation();
+ }
+
+ /* Private methods */
+
+ /// <summary>Adds the number of subtitles that the translation has more than the original subtitles.</summary>
+ private void AddExtraSubtitles (Subtitles subtitles, Subtitles translation) {
+ int translationCount = translation.Collection.Count;
+ int subtitlesCount = subtitles.Collection.Count;
+ int extraCount = translationCount - subtitlesCount;
+
+ if (extraCount <= 0)
+ return;
+
+ for (int position = subtitlesCount - 1 ; position < translationCount - 1 ; position++) {
+ subtitles.Collection.AddNewAfter(position, subtitles.Properties);
+ }
+ }
+
+ /// <summary>Copies the translation to the subtitles.</summary>
+ private void CopyTranslation (Subtitles subtitles, Subtitles translation) {
+ for (int subtitleNumber = 0 ; subtitleNumber < translation.Collection.Count ; subtitleNumber++) {
+ Subtitle translated = translation.Collection[subtitleNumber];
+ Subtitle original = subtitles.Collection[subtitleNumber];
+
+ string translatedText = translated.Text.Get();
+ original.Translation.Set(translatedText);
+ }
+ }
+
+}
+
+}
diff --git a/src/SubLib/Exceptions/EncodingNotSupportedException.cs b/src/SubLib/Exceptions/EncodingNotSupportedException.cs
new file mode 100644
index 0000000..a1778f6
--- /dev/null
+++ b/src/SubLib/Exceptions/EncodingNotSupportedException.cs
@@ -0,0 +1,36 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System;
+
+namespace SubLib.Exceptions {
+
+/// <summary>The exception that is thrown when an <see cref="System.Text.Encoding" /> is not supported by the platform.</summary>
+public class EncodingNotSupportedException : ApplicationException {
+ private static string defaultMessage = "The encoding is not supported by this platform.";
+
+ public EncodingNotSupportedException (string message) : base(message) {
+ }
+
+ public EncodingNotSupportedException() : base(defaultMessage) {
+ }
+
+}
+
+}
diff --git a/src/SubLib/Exceptions/UnknownEncodingException.cs b/src/SubLib/Exceptions/UnknownEncodingException.cs
new file mode 100644
index 0000000..488af46
--- /dev/null
+++ b/src/SubLib/Exceptions/UnknownEncodingException.cs
@@ -0,0 +1,36 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System;
+
+namespace SubLib.Exceptions {
+
+/// <summary>The exception that is thrown when the character encoding auto-detection failed.</summary>
+public class UnknownEncodingException : ApplicationException {
+ private static string defaultMessage = "Unable to auto-detect the file's character encoding.";
+
+ public UnknownEncodingException (string message) : base(message) {
+ }
+
+ public UnknownEncodingException() : base(defaultMessage) {
+ }
+
+}
+
+}
diff --git a/src/SubLib/Exceptions/UnknownSubtitleFormatException.cs b/src/SubLib/Exceptions/UnknownSubtitleFormatException.cs
new file mode 100644
index 0000000..6ec8b75
--- /dev/null
+++ b/src/SubLib/Exceptions/UnknownSubtitleFormatException.cs
@@ -0,0 +1,36 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System;
+
+namespace SubLib.Exceptions {
+
+/// <summary>The exception that is thrown when the subtitle format auto-detection failed.</summary>
+public class UnknownSubtitleFormatException : ApplicationException {
+ private static string defaultMessage = "Unable to auto-detect the subtitle's format.";
+
+ public UnknownSubtitleFormatException(string message) : base(message) {
+ }
+
+ public UnknownSubtitleFormatException() : base(defaultMessage) {
+ }
+
+}
+
+}
diff --git a/src/SubLib/IO/FileInputOutput.cs b/src/SubLib/IO/FileInputOutput.cs
new file mode 100644
index 0000000..da37c7d
--- /dev/null
+++ b/src/SubLib/IO/FileInputOutput.cs
@@ -0,0 +1,164 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.IO.Output;
+using System;
+using System.Collections;
+using System.IO;
+using System.Text;
+using org.mozilla.intl.chardet;
+
+namespace SubLib.IO {
+
+internal class FileInputOutput {
+
+ /// <summary>Opens a file for reading.</summary>
+ internal static FileStream OpenFileForReading (string fileName) {
+ return new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
+ }
+
+ /// <summary>Detects the possible code pages by reading a specified stream.</summary>
+ /// <remarks>The stream reader position is reset after reading.</remarks>
+ /// <returns>The detected code pages, which will have zero length if none was detected.</returns>
+ internal static int[] DetectCodePages (Stream stream){
+ const int BUFFERSIZE = 1024;
+ nsDetector detector = new nsDetector(nsPSMDetector.ALL);
+ detector.Init(null);
+
+ byte[] buffer = new byte[BUFFERSIZE] ;
+ int readLength = 0;
+ bool finished = false;
+
+ while (!finished) {
+ readLength = stream.Read(buffer, 0, buffer.Length);
+ if (readLength == 0)
+ break;
+
+ finished = detector.DoIt(buffer, readLength, false);
+ }
+ detector.Done();
+ stream.Seek(0, SeekOrigin.Begin);
+
+ string[] detectedEncodings = detector.getProbableCharsets();
+ VerboseConsole.WriteLine(DetectedEncodingsToString(detectedEncodings));
+
+ /* Check if no encoding was detected */
+ if (detectedEncodings[0] == "nomatch")
+ return new int[0];
+
+ return GetCodePages(detectedEncodings);
+ }
+
+ /// <summary>Reads a file, given its <see cref="FileStream" /> and <see cref="Encoding" />.</summary>
+ /// <param name="file">The <see cref="FileStream" />.</param>
+ /// <param name="encoding">The <see cref="Encoding" />.</param>
+ /// <param name="reposition">Whether to reposition the stream position to the beginning after reading.</param>
+ /// <remarks>The newlines are converted to unix type.</remarks>
+ /// <returns> The read text.</returns>
+ internal static string ReadFile (FileStream file, Encoding encoding, bool reposition) {
+ StreamReader reader = new StreamReader(file, encoding, false);
+ string text = reader.ReadToEnd();
+ if (reposition)
+ file.Seek(0, SeekOrigin.Begin);
+
+ return ConvertNewLinesToUnix(text);
+ }
+
+ internal static void WriteFile (string fileName, string text){
+ StreamWriter writer = OpenFileForWriting(fileName);
+ try {
+ writer.Write(text);
+ }
+ finally {
+ writer.Close();
+ }
+ }
+
+ internal static void WriteFile (string fileName, string text, Encoding encoding) {
+ StreamWriter writer = OpenFileForWriting(fileName, encoding);
+ try {
+ writer.Write(text);
+ }
+ finally {
+ writer.Close();
+ }
+ }
+
+
+ /* Private members */
+
+ private static StreamWriter OpenFileForWriting (string fileName) {
+ FileStream file = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
+ StreamWriter fileWriter = new StreamWriter(file);
+ return fileWriter;
+ }
+
+ private static StreamWriter OpenFileForWriting (string fileName, Encoding encoding) {
+ FileStream file = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
+ StreamWriter fileWriter = new StreamWriter(file, encoding);
+ return fileWriter;
+ }
+
+ private static int[] GetCodePages (string[] encodings) {
+ ArrayList codePages = new ArrayList();
+ foreach (string encoding in encodings) {
+ int codePage = GetCodePage(encoding);
+ if (codePage != -1)
+ codePages.Add(codePage);
+ }
+ return (int[])codePages.ToArray(typeof(int));
+ }
+
+ // Note: ISO-2022-CN, HZ-GB-2312 and x-euc-tw are not defined as their code pages were not found
+ private static int GetCodePage (string encoding) {
+ switch (encoding) {
+ case "UTF-8": return 65001;
+ case "windows-1252": return 1252;
+ case "UTF-16LE": return 1200;
+ case "UTF-16BE": return 1201;
+ case "Shift_JIS": return 932;
+ case "Big5": return 950;
+ case "ISO-2022-KR": return 50225;
+ case "ISO-2022-JP": return 50221;
+ case "GB2312": return 936;
+ case "GB18030": return 54936;
+ case "EUC-KR": return 51949;
+ case "EUC-JP": return 51932;
+ default: return -1;
+ }
+ }
+
+ private static string DetectedEncodingsToString (string[] detectedEncodings) {
+ string result = "Detected encodings:";
+ foreach (string encoding in detectedEncodings) {
+ result += " " + encoding;
+ }
+ return result;
+ }
+
+ /// <summary>Replaces the occurrences of Windows and Mac newline chars with unix newline.</summary>
+ private static string ConvertNewLinesToUnix (string text) {
+ text = text.Replace("\r\n", "\n"); //Replace Windows newline
+ text = text.Replace("\r", "\n"); //Replace Mac newline
+ return text;
+ }
+
+}
+
+}
diff --git a/src/SubLib/IO/Input/ParsingProperties.cs b/src/SubLib/IO/Input/ParsingProperties.cs
new file mode 100644
index 0000000..1f14c1c
--- /dev/null
+++ b/src/SubLib/IO/Input/ParsingProperties.cs
@@ -0,0 +1,45 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+
+namespace SubLib.IO.Input {
+
+internal class ParsingProperties {
+ private Headers headers = new Headers();
+ private TimingMode timingMode = TimingMode.Times;
+ private float originalFrameRate = 25;
+
+ public Headers Headers {
+ get { return headers; }
+ }
+
+ public TimingMode TimingMode {
+ get { return timingMode; }
+ set { timingMode = value; }
+ }
+
+ public float OriginalFrameRate {
+ get { return originalFrameRate; }
+ set { originalFrameRate = value; }
+ }
+
+}
+
+}
\ No newline at end of file
diff --git a/src/SubLib/IO/Input/PlainTextParser.cs b/src/SubLib/IO/Input/PlainTextParser.cs
new file mode 100644
index 0000000..334f93c
--- /dev/null
+++ b/src/SubLib/IO/Input/PlainTextParser.cs
@@ -0,0 +1,91 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.IO;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.Input {
+
+internal class PlainTextParser {
+
+ private bool withCharacterNames = false;
+ private string lineSeparator = String.Empty;
+ private string text = String.Empty;
+
+ internal PlainTextParser(bool withCharacterNames, string lineSeparator) {
+ this.withCharacterNames = withCharacterNames;
+ this.lineSeparator = lineSeparator;
+ }
+
+ internal PlainTextParser(bool withCharacterNames) : this(withCharacterNames, @"\n") {
+ }
+ /// <summary>Parses the specified text.</summary>
+ /// <remarks>The created <see cref="SubtitleCollection" /> will have its <see cref="SubtitleProperties" /> property set to null.
+ /// It is mandatory to use <see cref="SubtitleCollection.SetPropertiesForAll" /> after.</remarks>
+ internal ParsingProperties Parse (string text, TimingMode timingMode, Encoding encoding, out SubtitleCollection collection) {
+
+ collection = new SubtitleCollection();
+ ParsingProperties properties = new ParsingProperties();
+ this.text = text;
+ properties.TimingMode = timingMode;
+
+ /* Read the subtitles */
+ ReadSubtitles(encoding, properties, collection);
+
+ return properties;
+ }
+
+ private void ReadSubtitles (Encoding encoding, ParsingProperties properties, SubtitleCollection collection) {
+
+ string[] lines = text.Split(new char[] {'\n'});
+ for (int i = 0; i < lines.Length; i++) {
+ SubtitleText stext = ParseSubtitleText(lines[i]);
+ Style style = new Style();
+ if(!stext.IsEmpty) {
+ Subtitle subtitle = new Subtitle(null, stext, style);
+ collection.Add(subtitle);
+ }
+ }
+
+ }
+
+ private SubtitleText ParseSubtitleText (string line) {
+ string text = String.Empty;
+ if (withCharacterNames) {
+ string[] pieces = line.Split(new char[] { ':' });
+ if (pieces.Length > 1)
+ text = pieces[1];
+ else
+ text = pieces[0];
+ }
+ else
+ text = line;
+
+ if (text.Length > 0)
+ return new SubtitleText(text, lineSeparator, true);
+ else return new SubtitleText();
+
+ }
+
+}
+
+}
diff --git a/src/SubLib/IO/Input/SubtitleInput.cs b/src/SubLib/IO/Input/SubtitleInput.cs
new file mode 100644
index 0000000..f60f863
--- /dev/null
+++ b/src/SubLib/IO/Input/SubtitleInput.cs
@@ -0,0 +1,211 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using SubLib.Exceptions;
+using SubLib.IO.Output;
+using SubLib.IO.SubtitleFormats;
+using System;
+using System.IO;
+using System.Text;
+
+namespace SubLib.IO.Input {
+
+internal class SubtitleInput {
+ private Encoding fallbackEncoding = null;
+ private SubtitleType subtitleType = SubtitleType.Unknown;
+
+ internal SubtitleInput (Encoding fallbackEncoding, SubtitleType subtitleType) {
+ this.fallbackEncoding = fallbackEncoding;
+ this.subtitleType = subtitleType;
+ }
+
+ /// <exception cref="EncodingNotSupportedException">Thrown if the encoding is not supported by the platform.</exception>
+ /// <exception cref="UnknownSubtitleFormatException">Thrown if the subtitle format could not be detected.</exception>
+ internal string Read (string path, out Encoding encoding, out SubtitleFormat format) {
+ /* Open file */
+ FileStream fileStream = FileInputOutput.OpenFileForReading(path);
+
+ return ReadSubtitleText(true, fileStream, out encoding, out format);
+ }
+
+ /// <exception cref="UnknownSubtitleFormatException">Thrown if the subtitle format could not be detected.</exception>
+ internal string Read (string path, Encoding encoding, out SubtitleFormat format) {
+ /* Open file */
+ FileStream fileStream = FileInputOutput.OpenFileForReading(path);
+
+ /* Read the text */
+ return TestEncoding(fileStream, encoding, out format);
+ }
+
+ /// <exception cref="EncodingNotSupportedException">Thrown if the encoding is not supported by the platform.</exception>
+ internal string ReadPlain (string path, out Encoding encoding) {
+ /* Open file */
+ FileStream fileStream = FileInputOutput.OpenFileForReading(path);
+
+ SubtitleFormat format = null;
+ return ReadSubtitleText(false, fileStream, out encoding, out format);
+ }
+
+ /// <exception cref="EncodingNotSupportedException">Thrown if the encoding is not supported by the platform.</exception>
+ internal string ReadPlain (string path, Encoding encoding) {
+ /* Open file */
+ FileStream fileStream = FileInputOutput.OpenFileForReading(path);
+
+ /* Read the text */
+ return TestEncoding(fileStream, encoding);
+ }
+
+ /* Private methods */
+
+ /// <summary>Checks the encoding of a file.</summary>
+ /// <param name="isSubtitleFile">If it is a subtitle file or a plain text one.</param>
+ /// <param name="fileStream">The stream for reading the file.</param>
+ /// <param name="usedEncoding">The encoding supposedly used.</param>
+ /// <param name="usedFormat">The subtitle format used.</param>
+ /// <exception cref="EncodingNotSupportedException">Thrown if the encoding is not supported by the platform.</exception>
+ /// <exception cref="UnknownSubtitleFormatException">Thrown if the subtitle format could not be detected.</exception>
+ private string ReadSubtitleText (bool isSubtitleFile, FileStream fileStream, out Encoding usedEncoding, out SubtitleFormat usedFormat) {
+ /* Init the out arguments */
+ usedEncoding = null;
+ usedFormat = null;
+
+ /* Detect code pages */
+ int[] codePages = FileInputOutput.DetectCodePages(fileStream);
+
+ /* Check if no codepage was detected */
+ if (codePages.Length == 0) {
+ VerboseConsole.WriteLine("No encoding was automatically detected. Using the fall-back encoding: " + fallbackEncoding.WebName);
+ string text;
+ if (isSubtitleFile)
+ text = TestEncoding(fileStream, fallbackEncoding, out usedFormat);
+ else
+ text = TestEncoding(fileStream, fallbackEncoding);
+ usedEncoding = fallbackEncoding;
+ return text;
+ }
+
+ /* The first code page represents the most probable encoding. If any problem occurs when trying to use
+ * that code page, this problem is registered. The remaining code pages are then tried, and if none works,
+ * the first occuring error is the one to be reported. */
+ Exception firstEncodingException = null;
+ Exception firstSubtitleFormatException = null;
+ int firstCodePage = codePages[0];
+ try {
+ string text;
+ if (isSubtitleFile)
+ text = TestCodePage(fileStream, firstCodePage, out usedEncoding, out usedFormat);
+ else
+ text = TestCodePagePlain(fileStream, firstCodePage, out usedEncoding);
+ return text;
+ }
+ catch (EncodingNotSupportedException e) {
+ firstEncodingException = e;
+ }
+ catch (UnknownSubtitleFormatException e) {
+ firstSubtitleFormatException = e;
+ }
+
+ /* Problems were found, going to try additional code pages */
+ for (int count = 1 ; count < codePages.Length ; count++) {
+ try {
+ int codePage = codePages[count];
+ string text;
+ if (isSubtitleFile)
+ text = TestCodePage(fileStream, codePage, out usedEncoding, out usedFormat);
+ else
+ text = TestCodePagePlain(fileStream, codePage, out usedEncoding);
+ return text;
+ }
+ catch (Exception) {
+ //Don't do anything, will try the next code page
+ }
+ }
+
+ /* No code page worked, throwing the exceptions caught for the first (more probable) code page */
+ if (firstEncodingException != null)
+ throw firstEncodingException;
+ else
+ throw firstSubtitleFormatException;
+
+ }
+
+ /// <exception cref="EncodingNotSupportedException">Thrown if the encoding is not supported by the platform.</exception>
+ /// <exception cref="UnknownSubtitleFormatException">Thrown if the subtitle format could not be detected.</exception>
+ private string TestCodePage (FileStream fileStream, int codePage, out Encoding encoding, out SubtitleFormat format) {
+ /* Check the encoding */
+ TestCodePageCommon(codePage, out encoding);
+ return TestEncoding(fileStream, encoding, out format);
+ }
+
+ /// <exception cref="EncodingNotSupportedException">Thrown if the encoding is not supported by the platform.</exception>
+ private string TestCodePagePlain (FileStream fileStream, int codePage, out Encoding encoding) {
+ /* Check the encoding */
+ TestCodePageCommon(codePage, out encoding);
+ return TestEncoding(fileStream, encoding);
+ }
+
+ private void TestCodePageCommon (int codePage, out Encoding encoding) {
+ /* Check the encoding */
+ try {
+ encoding = Encoding.GetEncoding(codePage);
+ }
+ catch (Exception) {
+ throw new EncodingNotSupportedException();
+ }
+ }
+
+ /// <exception cref="UnknownSubtitleFormatException">Thrown if the subtitle format could not be detected.</exception>
+ private string TestEncoding (FileStream fileStream, Encoding encoding, out SubtitleFormat format) {
+ /* Get the text */
+ string text = TestEncoding(fileStream, encoding);
+
+ /* Check the subtitle format */
+ format = GetSubtitleFormat(text);
+
+ return text;
+ }
+
+ private string TestEncoding (FileStream fileStream, Encoding encoding) {
+ VerboseConsole.WriteLine("Trying the encoding " + encoding.WebName);
+ /* Get the text */
+ string text = FileInputOutput.ReadFile(fileStream, encoding, true);
+
+ return text;
+ }
+
+ /// <exception cref="UnknownSubtitleFormatException">Thrown if the subtitle format could not be detected.</exception>
+ private SubtitleFormat GetSubtitleFormat (string text) {
+ if (subtitleType == SubtitleType.Unknown)
+ VerboseConsole.WriteLine("Trying to autodetect the subtitle format.");
+ else
+ VerboseConsole.WriteLine("Trying the subtitle format " + subtitleType);
+
+ SubtitleFormat subtitleFormat = null;
+ if (subtitleType == SubtitleType.Unknown)
+ subtitleFormat = BuiltInSubtitleFormats.Detect(text);
+ else
+ subtitleFormat = BuiltInSubtitleFormats.GetFormat(subtitleType);
+
+ return subtitleFormat;
+ }
+
+}
+
+}
\ No newline at end of file
diff --git a/src/SubLib/IO/Input/SubtitleParser.cs b/src/SubLib/IO/Input/SubtitleParser.cs
new file mode 100644
index 0000000..79c5e25
--- /dev/null
+++ b/src/SubLib/IO/Input/SubtitleParser.cs
@@ -0,0 +1,576 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2009 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core;
+using SubLib.Core.Domain;
+using SubLib.Core.Timing;
+using SubLib.IO.SubtitleFormats;
+using System;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.Input {
+
+internal class SubtitleParser {
+ private bool includeIncompleteSubtitles = false;
+
+ /* Delegate to use when parsing headers */
+ private delegate bool ParseHeaderDelegate (Match match, ParsingProperties properties);
+
+ internal SubtitleParser(bool includeIncompleteSubtitles) {
+ this.includeIncompleteSubtitles = includeIncompleteSubtitles;
+ }
+
+ private string ClearComments (string text, SubtitleFormat format) {
+ if (format.HasComments) {
+ Regex regex = new Regex(format.Comments);
+ string clearText = regex.Replace(text, String.Empty);
+ return clearText;
+ }
+ else
+ return text;
+ }
+
+ /// <summary>Parses the specified text, using the specified format.</summary>
+ /// <remarks>The created <see cref="SubtitleCollection" /> will have its <see cref="SubtitleProperties" /> property set to null.
+ /// It is mandatory to use <see cref="SubtitleCollection.SetPropertiesForAll" /> after.</remarks>
+ internal ParsingProperties Parse (string text, SubtitleFormat format,
+ out SubtitleCollection collection, out IncompleteSubtitleCollection incompleteSubtitles){
+
+ collection = new SubtitleCollection();
+ incompleteSubtitles = new IncompleteSubtitleCollection();
+ ParsingProperties properties = new ParsingProperties();
+
+ Regex subtitleRegex = null;
+ int bodyIndex = 0;
+
+ text = ClearComments(text, format);
+
+ /* Read the headers if available */
+ if (format.Mode == SubtitleMode.Both) {
+ //Read headers to know if format is using Times or Frames
+ bodyIndex = text.Length;
+ int lastIndex = ReadHeaders(text, bodyIndex, format, properties);
+ subtitleRegex = CreateSubtitleRegex(format, properties.TimingMode);
+
+ /* Detect body index from matching the first subtitle or the end of headers */
+ bodyIndex = FindBodyIndex(text, format, subtitleRegex);
+ if (lastIndex > bodyIndex)
+ bodyIndex = lastIndex;
+ }
+ else {
+ //End of headers is detected by start of subtitles' body
+ properties.TimingMode = format.ModeAsTimingMode;
+ subtitleRegex = CreateSubtitleRegex(format);
+ bodyIndex = FindBodyIndex(text, format, subtitleRegex);
+ ReadHeaders(text, bodyIndex, format, properties);
+ }
+
+ /* Get properties from the whole input, if available */
+ format.GlobalInputGetProperties(text, properties);
+
+ int textLength = text.Length;
+
+ /* Read the subtitles */
+ bodyIndex = ReadSubtitles(text, bodyIndex, textLength, subtitleRegex, format,
+ properties, collection, incompleteSubtitles);
+
+ /* Read the end text of the subtitles */
+ bodyIndex = ReadBodyEnd(text, bodyIndex, format, collection, incompleteSubtitles);
+
+ /* Check if there's still text remaining */
+ if ((bodyIndex < textLength) && includeIncompleteSubtitles)
+ AddIncompleteSubtitle(incompleteSubtitles, text.Substring(bodyIndex), collection.Count);
+
+ return properties;
+ }
+
+
+ /* Private members */
+
+ private ParseHeaderDelegate GetHeaderParser (SubtitleType subtitleType) {
+ switch (subtitleType) {
+ case SubtitleType.SubViewer1:
+ return new ParseHeaderDelegate(ParseHeaderSubViewer1);
+ case SubtitleType.SubViewer2:
+ return new ParseHeaderDelegate(ParseHeaderSubViewer2);
+ case SubtitleType.KaraokeLyricsLRC:
+ return new ParseHeaderDelegate(ParseHeaderKaraokeLyricsLRC);
+ case SubtitleType.KaraokeLyricsVKT:
+ return new ParseHeaderDelegate(ParseHeaderKaraokeLyricsVKT);
+ case SubtitleType.MPSub:
+ return new ParseHeaderDelegate(ParseHeaderMPSub);
+ case SubtitleType.SubStationAlpha:
+ return new ParseHeaderDelegate(ParseHeaderSubStationAlphaAAS);
+ case SubtitleType.AdvancedSubStationAlpha:
+ return new ParseHeaderDelegate(ParseHeaderSubStationAlphaAAS);
+ default:
+ return null;
+ }
+ }
+
+ /// <returns>The index where subtitles start.</returns>
+ private int ReadHeaders (string text, int bodyIndex, SubtitleFormat format, ParsingProperties properties) {
+ if (!(format.HasHeaders && (bodyIndex > 0)))
+ return 0;
+
+ ParseHeaderDelegate headerParser = GetHeaderParser(format.Type);
+
+ int lastIndex = 0; //the last index with header text
+ string headerText = text.Substring(0, bodyIndex);
+ foreach (string headerExpression in format.Headers) {
+ Regex expression = new Regex(headerExpression, RegexOptions.IgnoreCase);
+ Match match = expression.Match(headerText, 0, bodyIndex);
+ if (match.Success) {
+ /* Update the last index based on the header match */
+ int matchLastIndex = match.Index + match.Length;
+ if (matchLastIndex > lastIndex)
+ lastIndex = matchLastIndex;
+
+ headerParser(match, properties);
+ }
+ }
+ return lastIndex;
+ }
+
+ private bool ParseHeaderSubViewer1 (Match match, ParsingProperties properties) {
+ return ParseHeaderSubViewer1(match, properties, properties.Headers);
+ }
+
+ private bool ParseHeaderSubViewer1 (Match match, ParsingProperties properties, Headers headers) {
+ string result = String.Empty;
+
+ if (ParseGroup(match, "Title", ref result))
+ headers.Title = result;
+ else if (ParseGroup(match, "Author", ref result))
+ headers.Author = result;
+ else if (ParseGroup(match, "Source", ref result))
+ headers.VideoSource = result;
+ else if (ParseGroup(match, "Program", ref result))
+ headers.Program = result;
+ else if (ParseGroup(match, "FilePath", ref result))
+ headers.SubtitlesSource = result;
+ else if (ParseGroup(match, "Delay", ref result))
+ headers.DelayAsText = result;
+ else if (ParseGroup(match, "CdTrack", ref result))
+ headers.CDTrackAsText = result;
+ else {
+ return false;
+ }
+ return true;
+ }
+
+ private bool ParseHeaderSubViewer2 (Match match, ParsingProperties properties) {
+ Headers headers = properties.Headers;
+ string result = String.Empty;
+
+ if (!ParseHeaderSubViewer1(match, properties, headers)) {
+ if (ParseGroup(match, "Comment", ref result))
+ headers.Comment = result;
+ else if (ParseGroup(match, "FontName", ref result))
+ headers.FontName = result;
+ else if (ParseGroup(match, "FontColor", ref result))
+ headers.FontColor = result;
+ else if (ParseGroup(match, "FontStyle", ref result))
+ headers.FontStyle = result;
+ else if (ParseGroup(match, "FontSize", ref result))
+ headers.FontSizeAsText = result;
+ else
+ return false;
+ }
+ return true;
+ }
+
+ private bool ParseHeaderKaraokeLyricsVKT (Match match, ParsingProperties properties) {
+ Headers headers = properties.Headers;
+ string result = String.Empty;
+
+ if (ParseGroup(match, "FrameRate", ref result))
+ headers.FrameRate = result;
+ else if (ParseGroup(match, "Author", ref result))
+ headers.Author = result;
+ else if (ParseGroup(match, "Source", ref result))
+ headers.VideoSource = result;
+ else if (ParseGroup(match, "Date", ref result))
+ headers.Date = result;
+ else {
+ return false;
+ }
+ return true;
+ }
+
+ private bool ParseHeaderKaraokeLyricsLRC (Match match, ParsingProperties properties) {
+ Headers headers = properties.Headers;
+ string result = String.Empty;
+
+ if (ParseGroup(match, "Title", ref result))
+ headers.Title = result;
+ else if (ParseGroup(match, "Author", ref result))
+ headers.MovieAuthor = result;
+ else if (ParseGroup(match, "Artist", ref result))
+ headers.Artist = result;
+ else if (ParseGroup(match, "Album", ref result))
+ headers.Album = result;
+ else if (ParseGroup(match, "Maker", ref result))
+ headers.Author = result;
+ else if (ParseGroup(match, "Version", ref result))
+ headers.Version = result;
+ else if (ParseGroup(match, "Program", ref result))
+ headers.Program = result;
+ else {
+ return false;
+ }
+ return true;
+ }
+
+ private bool ParseHeaderMPSub (Match match, ParsingProperties properties) {
+ Headers headers = properties.Headers;
+ string result = String.Empty;
+ float floatResult = 0;
+
+ if (ParseGroup(match, "Title", ref result))
+ headers.Title = result;
+ else if (ParseGroup(match, "File", ref result))
+ headers.FileProperties = result;
+ else if (ParseGroup(match, "Author", ref result))
+ headers.Author = result;
+ else if (ParseGroup(match, "MediaType", ref result))
+ headers.MediaType = result;
+ else if (ParseGroup(match, "Note", ref result))
+ headers.Comment = result;
+ //Used to detect if a subtitles' timing mode is Times in the case of a format that supports both
+ else if (ParseGroup(match, "TimingModeTimes", ref result))
+ properties.TimingMode = TimingMode.Times;
+ //Used to detect if a subtitles' timing mode is Frames in the case of a format that supports both
+ else if (ParseGroup(match, "TimingModeFrames", ref floatResult)) {
+ properties.TimingMode = TimingMode.Frames;
+ properties.OriginalFrameRate = floatResult;
+ }
+ else {
+ return false;
+ }
+ return true;
+ }
+
+ private bool ParseHeaderSubStationAlphaAAS (Match match, ParsingProperties properties) {
+ Headers headers = properties.Headers;
+ string result = String.Empty;
+ int intResult = 0;
+
+ if (ParseGroup(match, "Title", ref result))
+ headers.Title = result;
+ else if (ParseGroup(match, "OriginalScript", ref result))
+ headers.OriginalScript = result;
+ else if (ParseGroup(match, "OriginalTranslation", ref result))
+ headers.OriginalTranslation = result;
+ else if (ParseGroup(match, "OriginalEditing", ref result))
+ headers.OriginalEditing = result;
+ else if (ParseGroup(match, "OriginalTiming", ref result))
+ headers.OriginalTiming = result;
+ else if (ParseGroup(match, "OriginalScriptChecking", ref result))
+ headers.OriginalScriptChecking = result;
+ else if (ParseGroup(match, "ScriptUpdatedBy", ref result))
+ headers.ScriptUpdatedBy = result;
+ else if (ParseGroup(match, "Collisions", ref result))
+ headers.Collisions = result;
+ else if (ParseGroup(match, "PlayResX", ref intResult))
+ headers.PlayResX = intResult;
+ else if (ParseGroup(match, "PlayResY", ref intResult))
+ headers.PlayResY = intResult;
+ else if (ParseGroup(match, "PlayDepth", ref intResult))
+ headers.PlayDepth = intResult;
+ else if (ParseGroup(match, "Timer", ref result))
+ headers.Timer = result;
+ else {
+ return false;
+ }
+ return true;
+ }
+
+ private int ReadSubtitles (string text, int bodyIndex, int textLength, Regex subtitleRegex, SubtitleFormat format,
+ ParsingProperties properties, SubtitleCollection collection, IncompleteSubtitleCollection incompleteSubtitles) {
+
+ Subtitle previousSubtitle = null;
+
+ /* Read the subtitles. BodyIndex points to the start of the subtitles, skipping its possible beginning text*/
+ while (bodyIndex < textLength) {
+ Match match = subtitleRegex.Match(text, bodyIndex);
+ if (match.Success) {
+ Subtitle subtitle = ParseSubtitle(match, format, properties, previousSubtitle);
+ collection.Add(subtitle);
+ AddIncompleteSubtitleIfExists(text, match, bodyIndex, collection.Count, incompleteSubtitles);
+ bodyIndex = match.Index + match.Length;
+ previousSubtitle = subtitle;
+ }
+ else
+ break;
+ }
+ return bodyIndex;
+ }
+
+ private Subtitle ParseSubtitle (Match match, SubtitleFormat format, ParsingProperties properties, Subtitle previousSubtitle){
+ SubtitleText text = ParseSubtitleText(match, format);
+ Style style = ParseStyle(match, format);
+
+ Subtitle subtitle = new Subtitle(null, text, style);
+
+ if (properties.TimingMode == TimingMode.Frames) {
+ Frames previousFrames = (previousSubtitle == null ? null : previousSubtitle.Frames);
+ ParseFrames(match, subtitle.Frames, previousFrames);
+ }
+ else {
+ Times previousTimes = (previousSubtitle == null ? null : previousSubtitle.Times);
+ ParseTimes(match, subtitle.Times, previousTimes, properties);
+ }
+
+ format.SubtitleInputPostProcess(subtitle);
+ return subtitle;
+ }
+
+ private void ParseTimes (Match match, Times times, Times previousTimes, ParsingProperties properties) {
+ ParseStartTime(match, times, previousTimes, properties);
+ ParseEndTime(match, times, previousTimes, properties);
+ }
+
+ private void ParseStartTime (Match match, Times times, Times previousTimes, ParsingProperties properties) {
+ bool isTimeDefined = false;
+ TimeSpan startTime = new TimeSpan(0);
+
+ int result = 0;
+ float floatResult = 0;
+ if (ParseGroup(match, "StartHours", ref result)) {
+ startTime += TimeSpan.FromHours(result);
+ isTimeDefined = true;
+ }
+ if (ParseGroup(match, "StartMinutes", ref result)) {
+ startTime += TimeSpan.FromMinutes(result);
+ isTimeDefined = true;
+ }
+ if (ParseGroup(match, "StartSeconds", ref result)) {
+ startTime += TimeSpan.FromSeconds(result);
+ isTimeDefined = true;
+ }
+ if (ParseGroup(match, "StartDeciseconds", ref result)) {
+ startTime += TimeSpan.FromMilliseconds(result * 100);
+ isTimeDefined = true;
+ }
+ if (ParseGroup(match, "StartCentiseconds", ref result)) {
+ startTime += TimeSpan.FromMilliseconds(result * 10);
+ isTimeDefined = true;
+ }
+ if (ParseGroup(match, "StartMilliseconds", ref result)) {
+ startTime += TimeSpan.FromMilliseconds(result);
+ isTimeDefined = true;
+ }
+ if (ParseGroup(match, "StartMillisecondsAsFrames", ref result)) {
+ startTime += TimingUtil.FramesToTime(result, properties.OriginalFrameRate);
+ isTimeDefined = true;
+ }
+
+ if (ParseGroup(match, "StartElapsedTime", ref floatResult)) {
+ if (previousTimes != null)
+ startTime += previousTimes.PreciseEnd;
+
+ startTime += TimeSpan.FromSeconds(floatResult);
+ isTimeDefined = true;
+ }
+ if (isTimeDefined)
+ times.PreciseStart = startTime;
+ }
+
+ private void ParseEndTime (Match match, Times times, Times previousTimes, ParsingProperties properties) {
+ bool isTimeDefined = false;
+ TimeSpan endTime = new TimeSpan(0);
+
+ int result = 0;
+ float floatResult = 0;
+ if (ParseGroup(match, "EndHours", ref result)) {
+ endTime += TimeSpan.FromHours(result);
+ isTimeDefined = true;
+ }
+ if (ParseGroup(match, "EndMinutes", ref result)) {
+ endTime += TimeSpan.FromMinutes(result);
+ isTimeDefined = true;
+ }
+ if (ParseGroup(match, "EndSeconds", ref result)) {
+ endTime += TimeSpan.FromSeconds(result);
+ isTimeDefined = true;
+ }
+ if (ParseGroup(match, "EndDeciseconds", ref result)) {
+ endTime += TimeSpan.FromMilliseconds(result * 100);
+ isTimeDefined = true;
+ }
+ if (ParseGroup(match, "EndCentiseconds", ref result)) {
+ endTime += TimeSpan.FromMilliseconds(result * 10);
+ isTimeDefined = true;
+ }
+ if (ParseGroup(match, "EndMilliseconds", ref result)) {
+ endTime += TimeSpan.FromMilliseconds(result);
+ isTimeDefined = true;
+ }
+ if (ParseGroup(match, "EndMillisecondsAsFrames", ref result)) {
+ endTime += TimingUtil.FramesToTime(result, properties.OriginalFrameRate);
+ isTimeDefined = true;
+ }
+ if (ParseGroup(match, "EndElapsedTime", ref floatResult)) {
+ endTime += times.PreciseStart + TimeSpan.FromSeconds(floatResult);
+ isTimeDefined = true;
+ }
+ if (isTimeDefined)
+ times.PreciseEnd = endTime;
+ }
+
+ private void ParseFrames (Match match, Frames frames, Frames previousFrames) {
+ int result = 0;
+ if (ParseGroup(match, "StartFrame", ref result))
+ frames.PreciseStart = result;
+ else if (ParseGroup(match, "StartElapsedFrames", ref result)) {
+ double lastFrames = (previousFrames == null ? 0 : previousFrames.PreciseEnd);
+ frames.PreciseStart = lastFrames + result;
+ }
+
+ if (ParseGroup(match, "EndFrame", ref result))
+ frames.PreciseEnd = result;
+ else if (ParseGroup(match, "EndElapsedFrames", ref result)) {
+ frames.PreciseDuration = result;
+ }
+ }
+
+ private SubtitleText ParseSubtitleText (Match match, SubtitleFormat subtitleFormat) {
+ string text = String.Empty;
+ if (ParseGroup(match, "Text", ref text))
+ return new SubtitleText(text, subtitleFormat.LineBreak, true);
+ else
+ return new SubtitleText();
+ }
+
+ private Style ParseStyle (Match match, SubtitleFormat subtitleFormat) {
+ string styleText = String.Empty;
+ if (ParseGroup(match, "Style", ref styleText))
+ return subtitleFormat.StringToStyle(styleText);
+ else
+ return new Style();
+ }
+
+ private bool ParseGroup (Match match, string groupName, ref string result) {
+ Group group = match.Groups[groupName];
+ if (group.Success) {
+ result = group.Value.Trim();
+ return true;
+ }
+ else
+ return false;
+ }
+
+ private bool ParseGroup (Match match, string groupName, ref int result) {
+ string textResult = String.Empty;
+ bool returnValue = ParseGroup(match, groupName, ref textResult);
+ if (returnValue) {
+ try {
+ result = Convert.ToInt32(textResult);
+ } catch (Exception) {
+ return false;
+ }
+ }
+ return returnValue;
+ }
+
+ private bool ParseGroup (Match match, string groupName, ref float result) {
+ string textResult = String.Empty;
+ bool returnValue = ParseGroup(match, groupName, ref textResult);
+ if (returnValue) {
+ try {
+ result = (float)Convert.ToDouble(textResult);
+ } catch (Exception) {
+ return false;
+ }
+ }
+ return returnValue;
+ }
+
+ private int ReadBodyEnd (string text, int bodyIndex, SubtitleFormat format,
+ SubtitleCollection collection, IncompleteSubtitleCollection incompleteSubtitles) {
+
+ Regex bodyEnd = new Regex(format.BodyEndIn + @"\s*", RegexOptions.IgnoreCase);
+ Match bodyEndMatch = bodyEnd.Match(text, bodyIndex);
+ if (bodyEndMatch.Success) {
+ AddIncompleteSubtitleIfExists(text, bodyEndMatch, bodyIndex, collection.Count, incompleteSubtitles);
+ bodyIndex = bodyEndMatch.Index + bodyEndMatch.Length;
+ }
+ return bodyIndex;
+ }
+
+ private bool IsThereIncompleteText (Match match, int bodyIndex) {
+ return (match.Index > bodyIndex);
+ }
+
+ private void AddIncompleteSubtitle (IncompleteSubtitleCollection incompleteSubtitles, string incompleteText,
+ int previousSubtitle) {
+
+ if (!HasOnlyWhiteSpaces(incompleteText)) {
+ IncompleteSubtitle incompleteSubtitle = new IncompleteSubtitle(previousSubtitle, incompleteText);
+ incompleteSubtitles.Add(incompleteSubtitle);
+ }
+ }
+
+ private bool HasOnlyWhiteSpaces (string text) {
+ Regex emptyStringExpression = new Regex(@"\s*");
+ Match emptyStringMatch = emptyStringExpression.Match(text);
+ return (emptyStringMatch.Length == text.Length);
+ }
+
+ private int FindBodyIndex (string text, SubtitleFormat format, Regex subtitleRegex) {
+ if (format.HasHeaders || format.HasBodyBegin) {
+ Match subtitleMatch = subtitleRegex.Match(text);
+ if (subtitleMatch.Success) {
+ return subtitleMatch.Index;
+ }
+ }
+ return 0;
+ }
+
+ private Regex CreateSubtitleRegex(SubtitleFormat format) {
+ string subtitleInExpression = format.SubtitleIn + @"\s*"; //Ignore spaces between subtitles
+ return new Regex(subtitleInExpression, RegexOptions.IgnoreCase);
+ }
+
+ // Used when a subtitle format suppports both times and frames
+ private Regex CreateSubtitleRegex(SubtitleFormat format, TimingMode timingMode) {
+ string subtitleInExpression;
+ if (timingMode == TimingMode.Times)
+ subtitleInExpression = format.SubtitleInTimesMode + @"\s*"; //Ignore spaces between subtitles
+ else
+ subtitleInExpression = format.SubtitleInFramesMode + @"\s*"; //Ignore spaces between subtitles
+
+ return new Regex(subtitleInExpression, RegexOptions.IgnoreCase);
+ }
+
+ private void AddIncompleteSubtitleIfExists (string text, Match match, int bodyIndex,
+ int subtitleCount, IncompleteSubtitleCollection incompleteSubtitles) {
+
+ if (includeIncompleteSubtitles && IsThereIncompleteText(match, bodyIndex)) {
+ int length = match.Index - bodyIndex;
+ string incompleteText = text.Substring(bodyIndex, length);
+ AddIncompleteSubtitle(incompleteSubtitles, incompleteText, subtitleCount);
+ }
+ }
+
+}
+
+}
diff --git a/src/SubLib/IO/Output/SubtitleOutput.cs b/src/SubLib/IO/Output/SubtitleOutput.cs
new file mode 100644
index 0000000..83ff215
--- /dev/null
+++ b/src/SubLib/IO/Output/SubtitleOutput.cs
@@ -0,0 +1,229 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2009 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core;
+using SubLib.Core.Domain;
+using SubLib.Core.Timing;
+using SubLib.IO.SubtitleFormats;
+using System;
+using System.Collections;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.Output {
+
+internal class SubtitleOutput {
+ private SubtitleFormat format = null;
+ private SubtitleTextType textType = SubtitleTextType.Text;
+
+ private Subtitle subtitle = null;
+ private Subtitle previousSubtitle = null;
+ private int subtitleNumber = 1;
+
+ internal SubtitleOutput (SubtitleFormat format, SubtitleTextType textType) {
+ this.format = format;
+ this.textType = textType;
+ }
+
+ internal string Build (SubtitleCollection collection, SubtitleProperties subtitleProperties, FileProperties fileProperties) {
+ StringBuilder output = new StringBuilder();
+ if (format.HasHeaders)
+ output.Append(format.HeadersToString(subtitleProperties, fileProperties));
+
+ if (format.HasBodyBegin)
+ output.Append(format.BodyBeginOut);
+
+ string subtitleExpression = GetSubtitleExpression(format, subtitleProperties, fileProperties);
+ Regex fieldExpression = new Regex(@"<<(?<Field>\w+)(,(?<Width>\d+))?>>");
+ MatchEvaluator matchEvaluator = new MatchEvaluator(this.FieldEvaluator);
+
+ foreach (Subtitle currentSubtitle in collection) {
+ subtitle = currentSubtitle;
+ string outputSubtitle = fieldExpression.Replace(subtitleExpression, matchEvaluator);
+ output.Append(outputSubtitle);
+ output.Append("\n");
+ subtitleNumber++;
+ previousSubtitle = subtitle;
+ }
+
+ if (format.HasBodyEnd)
+ output.Append(format.BodyEndOut);
+
+ subtitle = null;
+ previousSubtitle = null;
+ subtitleNumber = 1;
+
+ ConvertNewlines(output, fileProperties);
+ return output.ToString();
+ }
+
+
+ /* Private members */
+
+ private string FieldEvaluator (Match match) {
+ Group fieldGroup = match.Groups["Field"];
+ string field = fieldGroup.Value;
+
+ switch (field) {
+ case "StartFrame":
+ int startFrame = subtitle.Frames.Start;
+ return FormatedField(startFrame, match);
+ case "StartElapsedFrames":
+ int previousFrames = (previousSubtitle == null ? 0 : previousSubtitle.Frames.End);
+ int startElapsedFrames = subtitle.Frames.Start - previousFrames;
+ return FormatedField(startElapsedFrames, match);
+ case "EndFrame":
+ int endFrame = subtitle.Frames.End;
+ return FormatedField(endFrame, match);
+ case "EndElapsedFrames":
+ int endElapsedFrames = subtitle.Frames.Duration;
+ return FormatedField(endElapsedFrames, match);
+ case "StartHours":
+ int startHours = subtitle.Times.Start.Hours;
+ return FormatedField(startHours, 2, match);
+ case "StartMinutes":
+ int startMinutes = subtitle.Times.Start.Minutes;
+ return FormatedField(startMinutes, 2, match);
+ case "StartSeconds":
+ int startSeconds = subtitle.Times.Start.Seconds;
+ return FormatedField(startSeconds, 2, match);
+ case "StartDeciseconds":
+ int startDeciseconds = DivideAndRound(subtitle.Times.Start.Milliseconds, 100);
+ return FormatedField(startDeciseconds, 2, match);
+ case "StartTotalDeciseconds":
+ int startTotalDeciseconds = DivideAndRound((int)subtitle.Times.Start.TotalMilliseconds, 100);
+ return startTotalDeciseconds.ToString();
+ case "StartCentiseconds":
+ int startCentiseconds = DivideAndRound(subtitle.Times.Start.Milliseconds, 10);
+ return FormatedField(startCentiseconds, 2, match);
+ case "StartMilliseconds":
+ int startMilliseconds = subtitle.Times.Start.Milliseconds;
+ return FormatedField(startMilliseconds, 3, match);
+ case "StartMillisecondsAsFramesPAL":
+ int startMillisecondsAsFramesPAL = (int)TimingUtil.TimeMillisecondsToFrames(subtitle.Times.Start.Milliseconds, 25);
+ return FormatedField(startMillisecondsAsFramesPAL, match);
+ case "StartMillisecondsAsFramesNTSC":
+ int startMillisecondsAsFramesNTSC = (int)TimingUtil.TimeMillisecondsToFrames(subtitle.Times.Start.Milliseconds, 29.97F);
+ return FormatedField(startMillisecondsAsFramesNTSC, match);
+ case "EndMillisecondsAsFramesPAL":
+ int endMillisecondsAsFramesPAL = (int)TimingUtil.TimeMillisecondsToFrames(subtitle.Times.End.Milliseconds, 25);
+ return FormatedField(endMillisecondsAsFramesPAL, match);
+ case "EndMillisecondsAsFramesNTSC":
+ int endMillisecondsAsFramesNTSC = (int)TimingUtil.TimeMillisecondsToFrames(subtitle.Times.End.Milliseconds, 29.97F);
+ return FormatedField(endMillisecondsAsFramesNTSC, match);
+ case "StartElapsedTime":
+ TimeSpan previousTime = (previousSubtitle == null ? TimeSpan.Zero : previousSubtitle.Times.End);
+ TimeSpan startElapsedTime = subtitle.Times.Start - previousTime;
+ return FormatedField(startElapsedTime.TotalSeconds);
+ case "EndHours":
+ int endHours = subtitle.Times.End.Hours;
+ return FormatedField(endHours, 2, match);
+ case "EndMinutes":
+ int endMinutes = subtitle.Times.End.Minutes;
+ return FormatedField(endMinutes, 2, match);
+ case "EndSeconds":
+ int endSeconds = subtitle.Times.End.Seconds;
+ return FormatedField(endSeconds, 2, match);
+ case "EndDeciseconds":
+ int endDeciseconds = DivideAndRound(subtitle.Times.End.Milliseconds, 100);
+ return FormatedField(endDeciseconds, 2, match);
+ case "EndTotalDeciseconds":
+ int endTotalDeciseconds = DivideAndRound((int)subtitle.Times.End.TotalMilliseconds, 100);
+ return endTotalDeciseconds.ToString();
+ case "EndCentiseconds":
+ int endCentiseconds = DivideAndRound(subtitle.Times.End.Milliseconds, 10);
+ return FormatedField(endCentiseconds, 2, match);
+ case "EndMilliseconds":
+ int endMilliseconds = subtitle.Times.End.Milliseconds;
+ return FormatedField(endMilliseconds, 3, match);
+ case "EndElapsedTime":
+ TimeSpan endElapsedTime = subtitle.Times.Duration;
+ return FormatedField(endElapsedTime.TotalSeconds);
+ case "Text":
+ SubtitleText subtitleText = (textType == SubtitleTextType.Text ? subtitle.Text : subtitle.Translation);
+ string text = subtitleText.GetTrimLines(format.LineBreak);
+ return text.ToString();
+ case "Style":
+ string style = format.StyleToString(subtitle.Style);
+ return style.ToString();
+ case "EndOfStyle":
+ string endOfStyle = format.EndOfStyleToString(subtitle.Style);
+ return endOfStyle.ToString();
+ case "SubtitleNumber":
+ return FormatedField(subtitleNumber, match);
+ default:
+ return match.Value;
+ }
+ }
+
+ private string FormatedField (int field, int defaultWidth, Match match) {
+ Group group = match.Groups["Width"];
+ int width = (group.Success ? Convert.ToInt32(group.Value) : defaultWidth);
+ return DimensionField(field, width);
+ }
+
+ private string FormatedField (int field, Match match) {
+ Group group = match.Groups["Width"];
+ if (group.Success) {
+ int width = Convert.ToInt32(group.Value);
+ return DimensionField(field, width);
+ }
+ else
+ return field.ToString();
+ }
+
+ private string FormatedField (double field) {
+ return field.ToString("0.###");
+ }
+
+ private string DimensionField (int field, int width) {
+ return field.ToString("D" + width).Substring(0, width);
+ }
+
+ private int DivideAndRound (int number, int denominator) {
+ return (int)Math.Round((double)number / denominator);
+ }
+
+ private void ConvertNewlines (StringBuilder builder, FileProperties properties) {
+ NewlineType type = properties.NewlineType;
+ if ((type == NewlineType.Unknown) || (type == NewlineType.Unix))
+ return;
+
+ string newline = (type == NewlineType.Windows ? "\r\n" : "\r"); //Windows : Macintosh
+ builder.Replace("\n", newline);
+ }
+
+ private string GetSubtitleExpression (SubtitleFormat format, SubtitleProperties subtitleProperties, FileProperties fileProperties) {
+ if (format.Mode == SubtitleMode.Both) {
+ if (fileProperties.TimingMode == TimingMode.Times)
+ return format.SubtitleOutTimesMode;
+ else
+ return format.SubtitleOutFramesMode;
+ }
+ else {
+ if (format.SubtitleOut != null)
+ return format.SubtitleOut;
+ else
+ return format.GetDynamicSubtitleOut(subtitleProperties);
+ }
+ }
+
+}
+
+}
diff --git a/src/SubLib/IO/Output/VerboseConsole.cs b/src/SubLib/IO/Output/VerboseConsole.cs
new file mode 100644
index 0000000..64b9615
--- /dev/null
+++ b/src/SubLib/IO/Output/VerboseConsole.cs
@@ -0,0 +1,44 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2006-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using System;
+
+namespace SubLib.IO.Output {
+
+internal class VerboseConsole {
+ private static bool verbose = false;
+
+ internal static bool Verbose {
+ get { return verbose; }
+ set { verbose = value; }
+ }
+
+ internal static void Write (string text) {
+ if (verbose)
+ Console.Write(text);
+ }
+
+ internal static void WriteLine (string text) {
+ if (verbose)
+ Console.WriteLine(text);
+ }
+
+}
+
+}
diff --git a/src/SubLib/IO/SubtitleFormats/BuiltInSubtitleFormats.cs b/src/SubLib/IO/SubtitleFormats/BuiltInSubtitleFormats.cs
new file mode 100644
index 0000000..7c0e140
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/BuiltInSubtitleFormats.cs
@@ -0,0 +1,84 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using SubLib.Exceptions;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal static class BuiltInSubtitleFormats {
+
+ /* Must be ordered with more precise/complex subtitle formats first, so simple/general/catch-all formats don't match other formats
+ * Must conform to the order in SubtitleType Enum */
+ private static SubtitleFormat[] subtitleFormats = {
+ new SubtitleFormatMicroDVD(),
+ new SubtitleFormatSubRip(),
+ new SubtitleFormatSubStationAlpha(),
+ new SubtitleFormatAdvancedSubStationAlpha(),
+ new SubtitleFormatMPlayer(),
+ new SubtitleFormatMPlayer2(),
+ new SubtitleFormatMPSub(),
+ new SubtitleFormatSubViewer1(),
+ new SubtitleFormatSubViewer2(),
+ new SubtitleFormatAQTitle(),
+ new SubtitleFormatMacSUB(),
+ new SubtitleFormatPhoenixJapanimationSociety(),
+ new SubtitleFormatPanimator(),
+ new SubtitleFormatSofni(),
+ new SubtitleFormatSubCreator1x(),
+ new SubtitleFormatViPlaySubtitleFile(),
+ new SubtitleFormatDKSSubtitleFormat(),
+ new SubtitleFormatPowerDivX(),
+ new SubtitleFormatKaraokeLyricsVKT(),
+ new SubtitleFormatKaraokeLyricsLRC(),
+ new SubtitleFormatAdobeEncoreDVD()
+ };
+
+ internal static SubtitleFormat[] SubtitleFormats {
+ get { return subtitleFormats; }
+ }
+
+ internal static SubtitleFormat GetFormat (SubtitleType subtitleType) {
+ if (subtitleType == SubtitleType.Unknown)
+ return null;
+ else
+ return subtitleFormats[(int)subtitleType - 1];
+ }
+
+ internal static SubtitleFormat Detect (string subtitleText) {
+ int lengthToTest = Math.Min(subtitleText.Length, 2000); //only use the first 2000 chars
+ foreach (SubtitleFormat format in BuiltInSubtitleFormats.SubtitleFormats) {
+ bool matchSuccess = TrySubtitleFormat(format, subtitleText, lengthToTest);
+ if (matchSuccess)
+ return format;
+ }
+ throw new UnknownSubtitleFormatException();
+ }
+
+ private static bool TrySubtitleFormat (SubtitleFormat format, string subtitleText, int length) {
+ Regex expression = new Regex(format.Format, RegexOptions.IgnoreCase);
+ Match match = expression.Match(subtitleText, 0, length);
+ return match.Success;
+ }
+
+}
+
+}
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormat.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormat.cs
new file mode 100644
index 0000000..9211f7e
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormat.cs
@@ -0,0 +1,194 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using SubLib.IO.Input;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal abstract class SubtitleFormat {
+
+ /* Required members */
+ protected string name; //the name of the format.
+ protected SubtitleType type; //the subtitle type
+ protected SubtitleMode mode; //the subtitle mode
+ protected string[] extensions; //the extensions used
+
+ protected string lineBreak; //used to split the subtitle's text lines
+ protected string format; //regex used to detect the file's format
+ protected string subtitleIn; //regex used to read a subtitle
+ protected string subtitleOut = null; //expression with tags used to write a subtitle; GetDynamicSubtitleOut can be used instead if the expression is dynamic
+
+ /* Optional members */
+ protected string[] headers = null; //used to read the subtitles' headers
+ protected string comments = String.Empty; //used to discard comments
+ protected string bodyBeginOut = String.Empty; //used to write the beginning of the subtitles' body
+ protected string bodyEndIn = String.Empty; //used to detect the end of the subtitles' body
+ protected string bodyEndOut = String.Empty; //used to write the end of the subtitles' body
+
+ /* Required members for subtitles that support both frames and times */
+ //The following two are used instead of subtitleIn
+ protected string subtitleInTimesMode = String.Empty; //regex used to read a subtitle in times mode
+ protected string subtitleInFramesMode = String.Empty; //regex used to read a subtitle in frames mode
+ //The following two are used instead of subtitleOut
+ protected string subtitleOutTimesMode = String.Empty; //regex used to output a subtitle in times mode
+ protected string subtitleOutFramesMode = String.Empty; //regex used to output a subtitle in times mode
+
+ internal string Name {
+ get { return name; }
+ }
+
+ internal SubtitleType Type {
+ get { return type; }
+ }
+
+ internal SubtitleMode Mode {
+ get { return mode; }
+ }
+
+ /// <remarks>Only use this when the Mode is not Both. This is provided as a convenience
+ /// for when the Mode is either Frames or Times.</remarks>
+ internal TimingMode ModeAsTimingMode {
+ get {
+ if (mode == SubtitleMode.Frames)
+ return TimingMode.Frames;
+ else
+ return TimingMode.Times;
+ }
+ }
+
+ internal string[] Extensions {
+ get { return extensions; }
+ }
+
+ internal string LineBreak {
+ get { return lineBreak; }
+ }
+
+ internal string Format {
+ get { return format; }
+ }
+
+ internal string SubtitleIn {
+ get { return subtitleIn; }
+ }
+
+ internal string SubtitleOut {
+ get { return subtitleOut; }
+ }
+
+ internal bool HasHeaders {
+ get { return headers != null; }
+ }
+
+ internal string[] Headers {
+ get { return headers; }
+ }
+
+ internal bool HasComments {
+ get { return comments != String.Empty; }
+ }
+
+ internal string Comments {
+ get { return comments; }
+ }
+
+ internal bool HasBodyBegin {
+ get { return bodyBeginOut != String.Empty; }
+ }
+
+ internal string BodyBeginOut {
+ get { return bodyBeginOut; }
+ }
+
+ internal bool HasBodyEnd {
+ get { return bodyEndOut != String.Empty; }
+ }
+
+ internal string BodyEndIn {
+ get { return bodyEndIn; }
+ }
+
+ internal string BodyEndOut {
+ get { return bodyEndOut; }
+ }
+
+ internal string SubtitleInTimesMode {
+ get { return subtitleInTimesMode; }
+ }
+
+ internal string SubtitleInFramesMode {
+ get { return subtitleInFramesMode; }
+ }
+
+ internal string SubtitleOutTimesMode {
+ get { return subtitleOutTimesMode; }
+ }
+
+ internal string SubtitleOutFramesMode {
+ get { return subtitleOutFramesMode; }
+ }
+
+ internal virtual Style StringToStyle (string styleText) {
+ Style style = new Style();
+ foreach (char character in styleText) {
+ if ((character == 'u') || (character == 'U'))
+ style.Underline = true;
+ else if ((character == 'b') || (character == 'B'))
+ style.Bold = true;
+ else if ((character == 'i') || (character == 'I'))
+ style.Italic = true;
+ }
+ return style;
+ }
+
+ internal virtual string StyleToString (Style style) {
+ return String.Empty;
+ }
+
+ internal virtual string EndOfStyleToString (Style style) {
+ return String.Empty;
+ }
+
+ internal virtual void SubtitleInputPostProcess (Subtitle subtitle) {
+ return;
+ }
+
+ internal virtual void GlobalInputGetProperties (string text, ParsingProperties properties) {
+ return;
+ }
+
+ internal virtual string GetDynamicSubtitleOut (SubtitleProperties properties) {
+ return null;
+ }
+
+ internal virtual string HeadersToString (SubtitleProperties subtitleProperties, FileProperties fileProperties) {
+ return String.Empty;
+ }
+
+ /* Public members */
+
+ public override string ToString(){
+ return Enum.GetName(typeof(SubtitleType), Type);
+ }
+}
+
+}
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatAQTitle.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatAQTitle.cs
new file mode 100644
index 0000000..19ab2b1
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatAQTitle.cs
@@ -0,0 +1,72 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatAQTitle : SubtitleFormat {
+ private static Regex styleExpression = new Regex(@"<[ubi]\w*>", RegexOptions.IgnoreCase);
+
+ internal SubtitleFormatAQTitle() {
+ name = "AQ Title";
+ type = SubtitleType.AQTitle;
+ mode = SubtitleMode.Frames;
+ extensions = new string[] { "aqt" };
+
+ lineBreak = "\n";
+
+ format = @"-->>\s*\d+\s+.+\s+-->>\s*\d+";
+
+ subtitleIn = @"-->>\s*(?<StartFrame>\d+)\s*(?<Text>.*\n.*)\n+-->>\s*(?<EndFrame>\d+)";
+
+ subtitleOut = "-->> <<StartFrame>>\n<<Text>>\n-->> <<EndFrame>>\n";
+
+ }
+
+ internal override string StyleToString (Style style) {
+ string styleText = String.Empty;
+ if (style.Underline)
+ styleText += "<u>";
+ if (style.Bold)
+ styleText += "<b>";
+ if (style.Italic)
+ styleText += "<i>";
+ return styleText;
+ }
+
+ // can be optimized
+ internal override void SubtitleInputPostProcess (Subtitle subtitle) {
+ string subtitleText = subtitle.Text.Get(lineBreak);
+ string styleText = String.Empty;
+ MatchCollection matches = styleExpression.Matches(subtitleText);
+ foreach (Match match in matches) {
+ styleText += match.Value;
+ }
+ Style style = StringToStyle(styleText);
+ subtitle.Style = style;
+ subtitleText = styleExpression.Replace(subtitleText, String.Empty);
+ subtitle.Text.Set(subtitleText, lineBreak, true);
+ }
+
+}
+
+}
\ No newline at end of file
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatAdobeEncoreDVD.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatAdobeEncoreDVD.cs
new file mode 100644
index 0000000..24b3850
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatAdobeEncoreDVD.cs
@@ -0,0 +1,74 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using SubLib.IO.Input;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatAdobeEncoreDVD : SubtitleFormat {
+ private Regex inputRegexPAL = new Regex(@"\d+(\s*:\s*\d+){3}\s+\d+(\s*:\s*\d+){3}\s*.+");
+
+ internal SubtitleFormatAdobeEncoreDVD () {
+ name = "Adobe Encore DVD";
+ type = SubtitleType.AdobeEncoreDVD;
+ mode = SubtitleMode.Times;
+ extensions = new string[] { "txt" };
+ lineBreak = "\n";
+
+ format = @"(\d+\s+)?\d+(\s*[:;]\s*\d+){3}\s+\d+(\s*[:;]\s*\d+){3}\s*.+";
+
+ subtitleIn = @"(\d+\s+)?(?<StartHours>\d+)\s*[:;]\s*(?<StartMinutes>\d+)\s*[:;]\s*(?<StartSeconds>\d+)\s*[:;]\s*(?<StartMillisecondsAsFrames>\d+)\s+(?<EndHours>\d+)\s*[:;]\s*(?<EndMinutes>\d+)\s*[:;]\s*(?<EndSeconds>\d+)\s*[:;]\s*(?<EndMillisecondsAsFrames>\d+)\s+(?<Text>((.(?!(\d+\s+)?\d+(\s*[:;]\s*\d+){3}))*\n)+)";
+
+ subtitleOut = null;
+ }
+
+ internal override string GetDynamicSubtitleOut (SubtitleProperties properties) {
+ bool isFrameRatePAL = IsFrameRatePAL(properties.CurrentFrameRate);
+ char sep = GetTimingSeparator(isFrameRatePAL);
+ string suf = GetFrameRateSuffix(isFrameRatePAL);
+ return "<<SubtitleNumber>> <<StartHours>>" + sep + "<<StartMinutes>>" + sep + "<<StartSeconds>>" + sep + "<<StartMillisecondsAsFrames" + suf + ">> <<EndHours>>" + sep + "<<EndMinutes>>" + sep + "<<EndSeconds>>" + sep + "<<EndMillisecondsAsFrames" + suf + ">> <<Text>>";
+ }
+
+ internal override void GlobalInputGetProperties (string text, ParsingProperties properties) {
+ bool isFrameRatePAL = inputRegexPAL.Match(text).Success;
+ float frameRate = (isFrameRatePAL ? 25 : 29.97F);
+ properties.OriginalFrameRate = frameRate;
+ }
+
+ /* Private members */
+ /// <summary>Returns the PAL (25) or NTSC (29.97) timing separator char, according to whether the frame rate is PAL or NTSC.</summary>
+ private char GetTimingSeparator (bool isFrameRatePAL) {
+ return (isFrameRatePAL ? ':' : ';');
+ }
+
+ private string GetFrameRateSuffix (bool isFrameRatePAL) {
+ return (isFrameRatePAL ? "PAL" : "NTSC");
+ }
+
+ /// <summary>Returns whether the frame rate is closer to PAL (25) or to NTSC (29.97).</summary>
+ private bool IsFrameRatePAL (float frameRate) {
+ return (Math.Abs(frameRate - 25) <= Math.Abs(frameRate - 29.97));
+ }
+
+}
+
+}
\ No newline at end of file
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatAdvancedSubStationAlpha.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatAdvancedSubStationAlpha.cs
new file mode 100644
index 0000000..67a4aa3
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatAdvancedSubStationAlpha.cs
@@ -0,0 +1,65 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2006-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatAdvancedSubStationAlpha : SubtitleFormatSubStationAlpha {
+
+ protected override string FormatName {
+ get { return "Advanced Sub Station Alpha"; }
+ }
+
+ protected override SubtitleType FormatType {
+ get { return SubtitleType.AdvancedSubStationAlpha; }
+ }
+
+ protected override string[] FormatExtensions {
+ get { return new string[] { "ass" }; }
+ }
+
+ protected override string FormatBodyBeginOut {
+ get { return "[Events]\nFormat: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text\n"; }
+ }
+
+ protected override string FormatSubtitleOut {
+ get { return "Dialogue: 0,<<StartHours,1>>:<<StartMinutes>>:<<StartSeconds>>.<<StartCentiseconds>>,<<EndHours,1>>:<<EndMinutes>>:<<EndSeconds>>.<<EndCentiseconds>>,Default,,0000,0000,0000,,<<Style>><<Text>><<EndOfStyle>>"; }
+ }
+
+ protected override string ScriptType {
+ get { return "v4.00+"; }
+ }
+
+ protected override string StyleTypeIn {
+ get { return @"V4\+"; }
+ }
+
+ protected override string StyleSection {
+ get {
+ return "[V4+ Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\n" +
+ "Style: Default,Tahoma,24,&H00FFFFFF,&H00FFFFFF,&H00FFFFFF,&H00C0C0C0,-1,0,0,0,100,100,0,0.00,1,2,3,2,20,20,20,1\n\n";
+ }
+ }
+
+}
+
+}
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatDKSSubtitleFormat.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatDKSSubtitleFormat.cs
new file mode 100644
index 0000000..41758e8
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatDKSSubtitleFormat.cs
@@ -0,0 +1,46 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatDKSSubtitleFormat : SubtitleFormat {
+
+ internal SubtitleFormatDKSSubtitleFormat () {
+ name = "DKS Subtitle Format";
+ type = SubtitleType.DKSSubtitleFormat;
+ mode = SubtitleMode.Times;
+ extensions = new string[] { "dks" };
+ lineBreak = "[br]";
+
+ format = @"\[\d+:\d+:\d+\]\s*.*\s*\[\d+:\d+:\d+\]";
+
+ subtitleIn = @"\[\s*(?<StartHours>\d+)\s*:\s*(?<StartMinutes>\d+)\s*:\s*(?<StartSeconds>\d+)\s*\]\s*(?<Text>.*)\s*\[\s*(?<EndHours>\d+)\s*:\s*(?<EndMinutes>\d+)\s*:\s*(?<EndSeconds>\d+)\s*\]";
+
+ subtitleOut = "[<<StartHours>>:<<StartMinutes>>:<<StartSeconds>>]<<Text>>\n" +
+ "[<<EndHours>>:<<EndMinutes>>:<<EndSeconds>>]\n";
+
+ }
+
+}
+
+}
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatKaraokeLyricsLRC.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatKaraokeLyricsLRC.cs
new file mode 100644
index 0000000..775ed44
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatKaraokeLyricsLRC.cs
@@ -0,0 +1,68 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatKaraokeLyricsLRC : SubtitleFormat {
+
+ internal SubtitleFormatKaraokeLyricsLRC() {
+ name = "Karaoke Lyrics LRC";
+ type = SubtitleType.KaraokeLyricsLRC;
+ mode = SubtitleMode.Times;
+ extensions = new string[] { "lrc" };
+
+ lineBreak = "|"; // It does not manage line breaks, but still using this char as a separator
+
+ format = @"\[\s*\d+:\d+.\d+\s*\].+\n+\[\s*\d+:\d+.\d+\s*\]";
+
+ subtitleIn = @"\[\s*(?<StartMinutes>\d+)\s*:\s*(?<StartSeconds>\d+)\s*.\s*(?<StartCentiseconds>\d+)\s*\]\s*(?<Text>.*)\n+\[\s*(?<EndMinutes>\d+)\s*:\s*(?<EndSeconds>\d+)\s*.\s*(?<EndCentiseconds>\d+)\s*\]";
+
+ subtitleOut = "[<<StartMinutes>>:<<StartSeconds>>.<<StartCentiseconds>>]<<Text>>\n" +
+ "[<<EndMinutes>>:<<EndSeconds>>.<<EndCentiseconds>>]";
+
+ headers = new string[] {
+ @"\[\s*ti:(?<Title>.*)\s*]" ,
+ @"\[\s*au:(?<Author>.*)\s*]" ,
+ @"\[\s*ar:(?<Artist>.*)\s*]" ,
+ @"\[\s*al:(?<Album>.*)\s*]" ,
+ @"\[\s*by:(?<Maker>.*)\s*]" ,
+ @"\[\s*ve:(?<Version>.*)\s*]" ,
+ @"\[\s*re:(?<Program>.*)\s*]"
+ };
+
+ }
+
+ internal override string HeadersToString (SubtitleProperties subtitleProperties, FileProperties fileProperties) {
+ Headers headers = subtitleProperties.Headers;
+ return "[ti: " + headers.Title + "]\n" +
+ "[au:" + headers.MovieAuthor + "]\n" +
+ "[ar:" + headers.Artist + "]\n" +
+ "[al:" + headers.Album + "]\n" +
+ "[by:" + headers.Author + "]\n" +
+ "[ve:" + headers.Version + "]\n" +
+ "[re:" + headers.Program + "]\n";
+ }
+}
+
+}
+
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatKaraokeLyricsVKT.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatKaraokeLyricsVKT.cs
new file mode 100644
index 0000000..bf81615
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatKaraokeLyricsVKT.cs
@@ -0,0 +1,66 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatKaraokeLyricsVKT : SubtitleFormat {
+
+ internal SubtitleFormatKaraokeLyricsVKT() {
+ name = "Karaoke Lyrics VKT";
+ type = SubtitleType.KaraokeLyricsVKT;
+ mode = SubtitleMode.Frames;
+ extensions = new string[] { "vkt" };
+
+ lineBreak = "|"; // It does not manage line breaks, but still using this char as a separator
+
+ format = @"\{\s*\d+\s*.+\s*\}\n+\{\s*\d+\s*\}";
+
+ subtitleIn = @"\{\s*(?<StartFrame>\d+)\s*(?<Text>.+)\}\n+\{\s*(?<EndFrame>\d+)\s*\}";
+
+ subtitleOut = "{<<StartFrame>> <<Text>>}\n{<<EndFrame>> }";
+
+ bodyEndIn = @"#\s*[\n#]+\s+THE END.";
+ bodyEndOut = "#\n# THE END.\n";
+
+ headers = new string[] {
+ @"FRAME RATE=(?<FrameRate>.*)" ,
+ @"CREATOR=(?<Author>.*)" ,
+ @"VIDEO SOURCE=(?<Source>.*)" ,
+ @"DATE=(?<Date>.*)"
+ };
+
+ }
+
+ internal override string HeadersToString(SubtitleProperties subtitleProperties, FileProperties fileProperties) {
+ Headers headers = subtitleProperties.Headers;
+ return "# <HEAD>\n" +
+ "# FRAME RATE=" + headers.FrameRate + "\n" +
+ "# CREATOR=" + headers.Author + "\n" +
+ "# VIDEO SOURCE=" + headers.VideoSource + "\n" +
+ "# DATE=" + headers.Date + "\n" +
+ "# </HEAD>\n#\n";
+ }
+}
+
+}
+
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatMPSub.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatMPSub.cs
new file mode 100644
index 0000000..697bcb4
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatMPSub.cs
@@ -0,0 +1,68 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2006-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatMPSub : SubtitleFormat {
+
+ internal SubtitleFormatMPSub () {
+ name = "MPSub";
+ type = SubtitleType.MPSub;
+ mode = SubtitleMode.Both;
+ extensions = new string[] { "sub" };
+ lineBreak = "\n";
+
+ format = @"TITLE\s*=(\n?(?!FORMAT).*(?!FORMAT))*[.\n]FORMAT\s*=\s*(TIME|\d+)\s*(\n?(?!\d+(.\d+)?[^\d\n]+\d+(.\d+)?).*(?!\d+(.\d+)?[^\d\n]+\d+(.\d+)?))*[.\n]\d+(.\d+)?[^\d\n]+\d+(.\d+)?";
+
+ subtitleInTimesMode = @"(?<StartElapsedTime>\d+(\.\d*)?)[^\d\n](?<EndElapsedTime>\d+(\.\d*)?).*(?<Text>(\n?.*(?!\n[ \f\r\t\v]*\n))*.)";
+ subtitleInFramesMode = @"(?<StartElapsedFrames>\d+)[^\d\n](?<EndElapsedFrames>\d+).*(?<Text>(\n?.*(?!\n[ \f\r\t\v]*\n))*.)";
+
+ subtitleOutTimesMode = "<<StartElapsedTime>> <<EndElapsedTime>>\n<<Text>>\n";
+ subtitleOutFramesMode = "<<StartElapsedFrames>> <<EndElapsedFrames>>\n<<Text>>\n";
+
+ comments = "#.*";
+
+ headers = new string[] {
+ @"TITLE\s*=(?<Title>.*)" ,
+ @"FILE\s*=(?<File>.*)" ,
+ @"AUTHOR\s*=(?<Author>.*)" ,
+ @"TYPE\s*=(?<MediaType>.*)" ,
+ @"FORMAT\s*=(?<TimingModeTimes>TIME)" ,
+ @"FORMAT\s*=(?<TimingModeFrames>\d+(.\d+)?)" ,
+ @"NOTE\s*=(?<Note>.*)"
+ };
+ }
+
+ internal override string HeadersToString (SubtitleProperties subtitleProperties, FileProperties fileProperties) {
+ Headers headers = subtitleProperties.Headers;
+ string format = (fileProperties.TimingMode == TimingMode.Times ? "TIME" : subtitleProperties.CurrentFrameRate.ToString());
+ return "TITLE=" + headers.Title + "\n" +
+ "FILE=" + headers.FileProperties + "\n" +
+ "AUTHOR=" + headers.Author + "\n" +
+ "TYPE=" + headers.MediaType + "\n" +
+ "FORMAT=" + format + "\n" +
+ "NOTE=" + headers.Comment + "\n\n";
+ }
+
+}
+
+}
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatMPlayer.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatMPlayer.cs
new file mode 100644
index 0000000..15e23f7
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatMPlayer.cs
@@ -0,0 +1,43 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2006-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatMPlayer : SubtitleFormat {
+
+ internal SubtitleFormatMPlayer () {
+ name = "MPlayer";
+ type = SubtitleType.MPlayer;
+ mode = SubtitleMode.Frames;
+ extensions = new string[] { "mpl" };
+ lineBreak = "|";
+
+ format = @"\d+,\d+,\d+,";
+
+ subtitleIn = @"(?<StartFrame>\d+)\s*,[^\d\n]*(?<EndFrame>\d+)\s*,[^\d\n]*\d+\s*,(?<Text>.*)";
+
+ subtitleOut = "<<StartFrame>>,<<EndFrame>>,0,<<Text>>";
+ }
+
+}
+
+}
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatMPlayer2.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatMPlayer2.cs
new file mode 100644
index 0000000..cb63986
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatMPlayer2.cs
@@ -0,0 +1,42 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2006-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatMPlayer2 : SubtitleFormat {
+
+ internal SubtitleFormatMPlayer2 () {
+ name = "MPlayer2";
+ type = SubtitleType.MPlayer2;
+ mode = SubtitleMode.Times;
+ extensions = new string[] { "mpl" };
+ lineBreak = "|";
+
+ format = @"\[\d+\]\[\d+\]";
+
+ subtitleIn = @"\[\s*(?<StartDeciseconds>\d+)\s*\]\[\s*(?<EndDeciseconds>\d+)\s*\](?<Text>.*)";
+
+ subtitleOut = "[<<StartTotalDeciseconds>>][<<EndTotalDeciseconds>>]<<Text>>";
+ }
+}
+
+}
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatMacSUB.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatMacSUB.cs
new file mode 100644
index 0000000..46ce1e4
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatMacSUB.cs
@@ -0,0 +1,46 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatMacSUB : SubtitleFormat {
+
+ internal SubtitleFormatMacSUB() {
+ name = "MacSUB";
+ type = SubtitleType.MacSUB;
+ mode = SubtitleMode.Frames;
+ extensions = new string[] { "scr" };
+
+ lineBreak = "\n";
+
+ format = @"/\s*\d+\s+.+\s+/\s*\d+";
+
+ subtitleIn = @"/\s*(?<StartFrame>\d+)\n+(?<Text>.+([^\d]\n.+)?)\n+/\s*(?<EndFrame>\d+)";
+
+ subtitleOut = "/<<StartFrame>>\n<<Text>>\n/<<EndFrame>>\n";
+
+ }
+
+}
+
+}
\ No newline at end of file
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatMicroDVD.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatMicroDVD.cs
new file mode 100644
index 0000000..91be652
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatMicroDVD.cs
@@ -0,0 +1,74 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatMicroDVD : SubtitleFormat {
+
+ internal SubtitleFormatMicroDVD () {
+ name = "Micro DVD";
+ type = SubtitleType.MicroDVD;
+ mode = SubtitleMode.Frames;
+ extensions = new string[] { "sub" };
+ lineBreak = "|";
+
+ format = @"\{\s*\d+\s*\}\s*\{\s*\d+\s*\}\s*.+";
+
+ subtitleIn = @"\{[^\d\n]*(?<StartFrame>\d+)[^\}\n]*\}([^\{\n]*\{[^\d\n]*(?<EndFrame>\d+)[^\}\n]*\})?(?<Text>.*)";
+
+ subtitleOut = "{<<StartFrame>>}{<<EndFrame>>}<<Style>><<Text>>";
+ }
+
+ private static Regex styleExpression = new Regex(@"\{[^Y]*Y[^:]*:\w*\}", RegexOptions.IgnoreCase);
+
+ internal override string StyleToString(Style style) {
+ string styleText = String.Empty;
+ if (style.Enabled) {
+ styleText += "{Y:";
+ if (style.Underline)
+ styleText += 'u';
+ if (style.Bold)
+ styleText += 'b';
+ if (style.Italic)
+ styleText += 'i';
+ styleText += '}';
+ }
+ return styleText;
+ }
+
+ internal override void SubtitleInputPostProcess (Subtitle subtitle) {
+ string subtitleText = subtitle.Text.Get(lineBreak);
+ string styleText = String.Empty;
+ MatchCollection matches = styleExpression.Matches(subtitleText);
+ foreach (Match match in matches) {
+ styleText += match.Value;
+ }
+ Style style = StringToStyle(styleText);
+ subtitle.Style = style;
+ subtitleText = styleExpression.Replace(subtitleText, String.Empty);
+ subtitle.Text.Set(subtitleText, lineBreak, true);
+ }
+
+}
+
+}
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatPanimator.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatPanimator.cs
new file mode 100644
index 0000000..02f7cff
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatPanimator.cs
@@ -0,0 +1,47 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatPanimator : SubtitleFormat {
+
+ internal SubtitleFormatPanimator() {
+ name = "Panimator";
+ type = SubtitleType.Panimator;
+ mode = SubtitleMode.Times;
+ extensions = new string[] { "pan" };
+
+ lineBreak = "\n";
+
+ format = @"/d\s+\d+\s+\d+\s+.+\s*/d\s+\d+\s+\d+\s+/c";
+
+ subtitleIn = @"/d\s+(?<StartSeconds>\d+)\s+(?<StartCentiseconds>\d+)\s+(?<Text>.+(\n.+)?)\s+/d\s+(?<EndSeconds>\d+)\s+(?<EndCentiseconds>\d+)\s+/c";
+
+ subtitleOut = "/d <<StartSeconds>> <<StartCentiseconds>>\n<<Text>>\n"
+ + "/d <<EndSeconds>> <<EndCentiseconds>>\n/c\n";
+
+ }
+
+}
+
+}
\ No newline at end of file
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatPhoenixJapanimationSociety.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatPhoenixJapanimationSociety.cs
new file mode 100644
index 0000000..56da802
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatPhoenixJapanimationSociety.cs
@@ -0,0 +1,46 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatPhoenixJapanimationSociety : SubtitleFormat {
+
+ internal SubtitleFormatPhoenixJapanimationSociety() {
+ name = "Phoenix Japanimation Society";
+ type = SubtitleType.PhoenixJapanimationSociety;
+ mode = SubtitleMode.Frames;
+ extensions = new string[] { "pjs" };
+
+ lineBreak = "|";
+
+ format = @"\s*\d+,\s*\d+,\s*"".+""";
+
+ subtitleIn = @"\s*(?<StartFrame>\d+),\s*(?<EndFrame>\d+),\s*""(?<Text>.+)""";
+
+ subtitleOut = "\t<<StartFrame>>,\t<<EndFrame>>, <<Text>>\n";
+
+ }
+
+}
+
+}
\ No newline at end of file
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatPowerDivX.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatPowerDivX.cs
new file mode 100644
index 0000000..cb30dc5
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatPowerDivX.cs
@@ -0,0 +1,45 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatPowerDivX : SubtitleFormat {
+
+ internal SubtitleFormatPowerDivX () {
+ name = "Power DivX";
+ type = SubtitleType.PowerDivX;
+ mode = SubtitleMode.Times;
+ extensions = new string[] { "psb" };
+ lineBreak = "|";
+
+ format = @"\{\s*\d+:\d+:\d+\s*\}\{\s*\d+:\d+:\d+\s*\}\s*.+";
+
+ subtitleIn = @"\{\s*(?<StartHours>\d+)\s*:\s*(?<StartMinutes>\d+)\s*:\s*(?<StartSeconds>\d+)\s*\}\s*\{\s*(?<EndHours>\d+)\s*:\s*(?<EndMinutes>\d+)\s*:\s*(?<EndSeconds>\d+)\s*\}\s*(?<Text>.*)";
+
+ subtitleOut = "{<<StartHours>>:<<StartMinutes>>:<<StartSeconds>>}" +
+ "{<<EndHours>>:<<EndMinutes>>:<<EndSeconds>>}<<Text>>";
+ }
+
+}
+
+}
\ No newline at end of file
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatSofni.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatSofni.cs
new file mode 100644
index 0000000..d6eca63
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatSofni.cs
@@ -0,0 +1,46 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatSofni : SubtitleFormat {
+
+ internal SubtitleFormatSofni () {
+ name = "Sofni";
+ type = SubtitleType.Sofni;
+ mode = SubtitleMode.Times;
+ extensions = new string[] { "sub" };
+ lineBreak = "\n";
+
+ format = @".+\s+\d+:\d+:\d+.\d+\\\d+:\d+:\d+.\d+";
+
+ subtitleIn = @"(?<Text>.+(\n.+)?)\n+(?<StartHours>\d+)\s*:\s*(?<StartMinutes>\d+)\s*:\s*(?<StartSeconds>\d+)\s*.\s*(?<StartCentiseconds>\d+)\\(?<EndHours>\d+)\s*:\s*(?<EndMinutes>\d+)\s*:\s*(?<EndSeconds>\d+)\s*.\s*(?<EndCentiseconds>\d+)";
+
+ subtitleOut = "<<Text>>\n" +
+ "<<StartHours>>:<<StartMinutes>>:<<StartSeconds>>.<<StartCentiseconds>>" +
+ "\\ <<EndHours>>:<<EndMinutes>>:<<EndSeconds>>.<<EndCentiseconds>>\n";
+ }
+
+}
+
+}
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatSubCreator1x.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatSubCreator1x.cs
new file mode 100644
index 0000000..3344103
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatSubCreator1x.cs
@@ -0,0 +1,45 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatSubCreator1x : SubtitleFormat {
+
+ internal SubtitleFormatSubCreator1x () {
+ name = "SubCreator 1.x";
+ type = SubtitleType.SubCreator1x;
+ mode = SubtitleMode.Times;
+ extensions = new string[] { "txt" };
+ lineBreak = "|";
+
+ format = @"\d+:\d+:\d+.\d:\s*.+\s+\d+:\d+:\d+.\d:";
+
+ subtitleIn = @"(?<StartHours>\d+):(?<StartMinutes>\d+):(?<StartSeconds>\d+).(?<StartDeciseconds>\d+):\s*(?<Text>.+)\s+(?<EndHours>\d+):(?<EndMinutes>\d+):(?<EndSeconds>\d+).(?<EndDeciseconds>\d+)";
+
+ subtitleOut = "<<StartHours>>:<<StartMinutes>>:<<StartSeconds>>.<<StartDeciseconds>>:" +
+ "<<Text>>\n<<EndHours>>:<<EndMinutes>>:<<EndSeconds>>.<<EndDeciseconds>>:\n";
+ }
+
+}
+
+}
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatSubRip.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatSubRip.cs
new file mode 100644
index 0000000..960aa6c
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatSubRip.cs
@@ -0,0 +1,83 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2005-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatSubRip : SubtitleFormat {
+ private static Regex styleExpression = new Regex(@"</?[^ubi\n]*[ubi]\w*>", RegexOptions.IgnoreCase);
+
+ internal SubtitleFormatSubRip () {
+ name = "SubRip";
+ type = SubtitleType.SubRip;
+ mode = SubtitleMode.Times;
+ extensions = new string[] { "srt" };
+ lineBreak = "\n";
+
+ format = @"\d+[ \f\r\t\v]*\n\d+(\s*:\s*\d+){2}\s*,\s*\d+\s*-->\s*\d+(\s*:\s*\d+){2}\s*,\d+[ \f\r\t\v]*\n.+";
+
+ subtitleIn = @"(\d*[^\n]*\n)?((?<StartHours>\d+)[^\d\n]+)?(?<StartMinutes>\d+)[^\d\n]+(?<StartSeconds>\d+)([^\d\n](?<StartMilliseconds>\d+))?[^\d\n]+((?<EndHours>\d+)[^\d\n]+)?(?<EndMinutes>\d+)[^\d\n]+(?<EndSeconds>\d+)([^\d\n](?<EndMilliseconds>\d+))?[^\d\n]*(\n(?<Text>(.*(?!\n[ \f\r\t\v]*\d+[ \f\r\t\v]*\n\d+(\s*:\s*\d+){2})\n?)*.))?";
+
+ subtitleOut = "<<SubtitleNumber>>\n" +
+ "<<StartHours>>:<<StartMinutes>>:<<StartSeconds>>,<<StartMilliseconds>> --> <<EndHours>>:<<EndMinutes>>:<<EndSeconds>>,<<EndMilliseconds>>\n" +
+ "<<Style>><<Text>><<EndOfStyle>>\n";
+ }
+
+ internal override string StyleToString (Style style) {
+ string styleText = String.Empty;
+ if (style.Underline)
+ styleText += "<u>";
+ if (style.Bold)
+ styleText += "<b>";
+ if (style.Italic)
+ styleText += "<i>";
+ return styleText;
+ }
+
+ internal override string EndOfStyleToString (Style style) {
+ string styleText = String.Empty;
+ if (style.Underline)
+ styleText += "</u>";
+ if (style.Bold)
+ styleText += "</b>";
+ if (style.Italic)
+ styleText += "</i>";
+ return styleText;
+ }
+
+ // can be optimized
+ internal override void SubtitleInputPostProcess (Subtitle subtitle) {
+ string subtitleText = subtitle.Text.Get(lineBreak);
+ string styleText = String.Empty;
+ MatchCollection matches = styleExpression.Matches(subtitleText);
+ foreach (Match match in matches) {
+ styleText += match.Value;
+ }
+ Style style = StringToStyle(styleText);
+ subtitle.Style = style;
+ subtitleText = styleExpression.Replace(subtitleText, String.Empty);
+ subtitle.Text.Set(subtitleText, lineBreak, true);
+ }
+
+}
+
+}
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatSubStationAlpha.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatSubStationAlpha.cs
new file mode 100644
index 0000000..81ee160
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatSubStationAlpha.cs
@@ -0,0 +1,172 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2006-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatSubStationAlpha : SubtitleFormat {
+ private static Regex styleExpression = new Regex(@"\{\\[ubi]\d\}", RegexOptions.IgnoreCase);
+
+ internal SubtitleFormatSubStationAlpha () {
+ name = FormatName;
+ type = FormatType;
+ extensions = FormatExtensions;
+
+ mode = SubtitleMode.Times;
+ lineBreak = @"\N";
+
+ format = @"\[\s*" + StyleTypeIn + @"\s*Styles\s*\][^\[]*\[\s*Events\s*\]\s*Format:\s*[^,\n]*(,[^,\n]*){9}";
+
+ subtitleIn = @"Dialogue:[^,]*,(?<StartHours>\d+):(?<StartMinutes>\d+):(?<StartSeconds>\d+)\.(?<StartCentiseconds>\d+),(?<EndHours>\d+):(?<EndMinutes>\d+):(?<EndSeconds>\d+)\.(?<EndCentiseconds>\d+)(,[^,]*){6},(?<Text>.*)";
+
+ subtitleOut = FormatSubtitleOut;
+ bodyBeginOut = FormatBodyBeginOut;
+
+ headers = new string[] {
+ @"Title:(?<Title>.*)" ,
+ @"Original\s*Script:(?<OriginalScript>.*)" ,
+ @"Original\s*Translation:(?<OriginalTranslation>.*)" ,
+ @"Original\s*Editing:(?<OriginalEditing>.*)" ,
+ @"Original\s*Timing:(?<OriginalTiming>.*)" ,
+ @"Original\s*Script\s*Checking:(?<OriginalScriptChecking>.*)" ,
+ @"Script\s*Updated\s*By:(?<ScriptUpdatedBy>.*)" ,
+ @"Collisions:(?<Collisions>.*)" ,
+ @"PlayResX:\s*(?<PlayResX>\d*)" ,
+ @"PlayResY:\s*(?<PlayResY>\d*)" ,
+ @"PlayDepth:\s*(?<PlayDepth>\d*)" ,
+ @"Timer:(?<Timer>.*)"
+ };
+ }
+
+ internal override string StyleToString (Style style) {
+ return StyleToString(style, "1");
+ }
+
+ internal override string EndOfStyleToString (Style style) {
+ return StyleToString(style, "0");
+ }
+
+ internal override void SubtitleInputPostProcess (Subtitle subtitle) {
+ string subtitleText = subtitle.Text.Get(lineBreak);
+ string styleText = String.Empty;
+ MatchCollection matches = styleExpression.Matches(subtitleText);
+ foreach (Match match in matches) {
+ styleText += match.Value;
+ }
+ Style style = StringToStyle(styleText);
+ subtitle.Style = style;
+ subtitleText = styleExpression.Replace(subtitleText, String.Empty);
+ subtitle.Text.Set(subtitleText, lineBreak, true);
+ }
+
+ internal override string HeadersToString (SubtitleProperties subtitleProperties, FileProperties fileProperties) {
+ Headers headers = subtitleProperties.Headers;
+ return "[Script Info]\n" +
+ Header("Title:", headers.Title, "<untitled>") +
Header("Original Script:", headers.OriginalScript, "<unknown>") +
+ "Script Type: " + ScriptType + "\n" +
+ Header("Original Translation:", headers.OriginalTranslation) +
+ Header("Original Editing:", headers.OriginalEditing) +
+ Header("Original Timing:", headers.OriginalTiming) +
+ Header("Original Script Checking:", headers.OriginalScriptChecking) +
+ Header("Script Updated By:", headers.ScriptUpdatedBy) +
+ Header("Collisions:", headers.Collisions) +
+ Header("PlayResX:", headers.PlayResX) +
+ Header("PlayResY:", headers.PlayResY) +
+ Header("PlayDepth:", headers.PlayDepth) +
+ Header("Timer:", headers.Timer) + "\n" +
+ StyleSection;
+ }
+
+ /* Protected members */
+
+ protected virtual string FormatName {
+ get { return "Sub Station Alpha"; }
+ }
+
+ protected virtual SubtitleType FormatType {
+ get { return SubtitleType.SubStationAlpha; }
+ }
+
+ protected virtual string[] FormatExtensions {
+ get { return new string[] { "ssa" }; }
+ }
+
+ protected virtual string FormatBodyBeginOut {
+ get { return "[Events]\nFormat: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\n"; }
+ }
+
+ protected virtual string FormatSubtitleOut {
+ get { return "Dialogue: Marked=0,<<StartHours,1>>:<<StartMinutes>>:<<StartSeconds>>.<<StartCentiseconds>>,<<EndHours,1>>:<<EndMinutes>>:<<EndSeconds>>.<<EndCentiseconds>>,Default,NTP,0000,0000,0000,!Effect,<<Style>><<Text>><<EndOfStyle>>"; }
+ }
+
+ protected virtual string ScriptType {
+ get { return "v4.00"; }
+ }
+
+ protected virtual string StyleTypeIn {
+ get { return "V4"; }
+ }
+
+ protected virtual string StyleSection {
+ get {
+ return "[V4 Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding\n" +
+ "Style: Default,Tahoma,24,16777215,16777215,16777215,0,-1,0,1,1,1,2,10,10,30,0,0\n\n";
+ }
+ }
+
+ /* Private members */
+
+ private string Header (string headerIntro, string headerValue, string defaultValue) {
+ if (headerValue == String.Empty)
+ return headerIntro + " " + defaultValue + "\n";
+ else
+ return headerIntro + " " + headerValue + "\n";
+ }
+
+ private string Header (string headerIntro, string headerValue) {
+ if (headerValue == String.Empty)
+ return String.Empty;
+ else
+ return headerIntro + " " + headerValue + "\n";
+ }
+
+ private string Header (string headerIntro, int headerValue) {
+ if (headerValue == -1)
+ return String.Empty;
+ else
+ return headerIntro + " " + headerValue + "\n";
+ }
+
+ protected string StyleToString (Style style, string suffix) {
+ string styleText = String.Empty;
+ if (style.Underline)
+ styleText += @"{\u" + suffix + "}";
+ if (style.Bold)
+ styleText += @"{\b" + suffix + "}";
+ if (style.Italic)
+ styleText += @"{\i" + suffix + "}";
+ return styleText;
+ }
+
+}
+
+}
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatSubViewer1.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatSubViewer1.cs
new file mode 100644
index 0000000..daf426a
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatSubViewer1.cs
@@ -0,0 +1,72 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2006-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatSubViewer1 : SubtitleFormat {
+
+ internal SubtitleFormatSubViewer1 () {
+ name = "SubViewer 1.0";
+ type = SubtitleType.SubViewer1;
+ mode = SubtitleMode.Times;
+ extensions = new string[] { "sub" };
+ lineBreak = "|";
+
+ format = @"\**\s*START\s*SCRIPT\s*\**[^\[]*\[\d+:\d+:\d+\]\s*.*\s*\[\d+:\d+:\d+\]";
+
+ subtitleIn = @"\[\s*(?<StartHours>\d+)\s*:\s*(?<StartMinutes>\d+)\s*:\s*(?<StartSeconds>\d+)\s*\]\s*(?<Text>.*)\s*\[\s*(?<EndHours>\d+)\s*:\s*(?<EndMinutes>\d+)\s*:\s*(?<EndSeconds>\d+)\s*\]";
+
+ subtitleOut = "[<<StartHours>>:<<StartMinutes>>:<<StartSeconds>>]\n" +
+ "<<Text>>\n" +
+ "[<<EndHours>>:<<EndMinutes>>:<<EndSeconds>>]\n";
+
+ bodyEndIn = @"\[\s*end\s*\]\s*\**\s*END\s*SCRIPT\s*\**";
+
+ bodyBeginOut = "[BEGIN]\n******** START SCRIPT ********\n";
+ bodyEndOut = "[end]\n******** END SCRIPT ********\n";
+
+ headers = new string[] {
+ @"\[\s*TITLE\s*\].*\n(?<Title>.*)" ,
+ @"\[\s*AUTHOR\s*\].*\n(?<Author>.*)" ,
+ @"\[\s*SOURCE\s*\].*\n(?<Source>.*)" ,
+ @"\[\s*PRG\s*\].*\n(?<Program>.*)" ,
+ @"\[\s*FILEPATH\s*\].*\n(?<FilePath>.*)" ,
+ @"\[\s*DELAY\s*\].*\n(?<Delay>.*)" ,
+ @"\[\s*CD\s*TRACK\s*\].*\n(?<CdTrack>.*)"
+ };
+ }
+
+ internal override string HeadersToString (SubtitleProperties subtitleProperties, FileProperties fileProperties) {
+ Headers headers = subtitleProperties.Headers;
+ return "[TITLE]\n" + headers.Title + "\n" +
+ "[AUTHOR]\n" + headers.Author + "\n" +
+ "[SOURCE]\n" + headers.VideoSource + "\n" +
+ "[PRG]\n" + headers.Program + "\n" +
+ "[FILEPATH]\n" + headers.SubtitlesSource + "\n" +
+ "[DELAY]\n" + headers.Delay + "\n" +
+ "[CD TRACK]\n" + headers.CDTrack + "\n";
+ }
+
+}
+
+}
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatSubViewer2.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatSubViewer2.cs
new file mode 100644
index 0000000..dcecf04
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatSubViewer2.cs
@@ -0,0 +1,76 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2006-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatSubViewer2 : SubtitleFormat {
+
+ internal SubtitleFormatSubViewer2 () {
+ name = "SubViewer 2.0";
+ type = SubtitleType.SubViewer2;
+ mode = SubtitleMode.Times;
+ extensions = new string[] { "sub" };
+ lineBreak = "[br]";
+
+ format = @"\d\d:\d\d:\d\d.\d\d,\d\d:\d\d:\d\d.\d\d";
+
+ subtitleIn = @"(?<StartHours>\d+)\s*:\s*(?<StartMinutes>\d+)\s*:\s*(?<StartSeconds>\d+)\s*\.\s*(?<StartCentiseconds>\d+)\s*,\s*(?<EndHours>\d+)\s*:\s*(?<EndMinutes>\d+)\s*:\s*(?<EndSeconds>\d+)\s*\.\s*(?<EndCentiseconds>\d+).*\n(?<Text>.*)";
+
+ subtitleOut = "<<StartHours>>:<<StartMinutes>>:<<StartSeconds>>.<<StartCentiseconds>>,<<EndHours>>:<<EndMinutes>>:<<EndSeconds>>.<<EndCentiseconds>>\n<<Text>>\n";
+
+ headers = new string[] {
+ @"\[\s*TITLE\s*\](?<Title>.*)" ,
+ @"\[\s*AUTHOR\s*\](?<Author>.*)" ,
+ @"\[\s*SOURCE\s*\](?<Source>.*)" ,
+ @"\[\s*PRG\s*\](?<Program>.*)" ,
+ @"\[\s*FILEPATH\s*\](?<FilePath>.*)" ,
+ @"\[\s*DELAY\s*\](?<Delay>.*)" ,
+ @"\[\s*CD\s*TRACK\s*\](?<CdTrack>.*)" ,
+ @"\[\s*COMMENT\s*\](?<Comment>.*)" ,
+ @"\[\s*COLF\s*\](?<FontColor>[^,\[\n]*)" ,
+ @"\[\s*STYLE\s*\](?<FontStyle>[^,\[\n]*)" ,
+ @"\[\s*SIZE\s*\](?<FontSize>[^,\[\n]*)" ,
+ @"\[\s*FONT\s*\](?<FontName>[^,\[\n]*)"
+ };
+ }
+
+ internal override string HeadersToString (SubtitleProperties subtitleProperties, FileProperties fileProperties) {
+ Headers headers = subtitleProperties.Headers;
+ return "[INFORMATION]\n" +
+ "[TITLE]" + headers.Title + "\n" +
+ "[AUTHOR]" + headers.Author + "\n" +
+ "[SOURCE]" + headers.VideoSource + "\n" +
+ "[PRG]" + headers.Program + "\n" +
+ "[FILEPATH]" + headers.SubtitlesSource + "\n" +
+ "[DELAY]" + headers.Delay + "\n" +
+ "[CD TRACK]" + headers.CDTrack + "\n" +
+ "[COMMENT]" + headers.Comment + "\n" +
+ "[END INFORMATION]\n" +
+ "[SUBTITLE]\n" +
+ "[COLF]" + headers.FontColor + ",[STYLE]" + headers.FontStyle +
+ ",[SIZE]" + headers.FontSize + ",[FONT]" + headers.FontName + "\n";
+ }
+
+}
+
+}
diff --git a/src/SubLib/IO/SubtitleFormats/SubtitleFormatViPlaySubtitleFile.cs b/src/SubLib/IO/SubtitleFormats/SubtitleFormatViPlaySubtitleFile.cs
new file mode 100644
index 0000000..158a82b
--- /dev/null
+++ b/src/SubLib/IO/SubtitleFormats/SubtitleFormatViPlaySubtitleFile.cs
@@ -0,0 +1,74 @@
+/*
+ * This file is part of SubLib.
+ * Copyright (C) 2007-2008 Pedro Castro
+ *
+ * SubLib 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SubLib 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+using SubLib.Core.Domain;
+using System;
+using System.Text.RegularExpressions;
+
+namespace SubLib.IO.SubtitleFormats {
+
+internal class SubtitleFormatViPlaySubtitleFile : SubtitleFormat {
+ private static Regex styleExpression = new Regex(@"<[ubi]\w*>", RegexOptions.IgnoreCase);
+
+ internal SubtitleFormatViPlaySubtitleFile () {
+ name = "ViPlay Subtitle File";
+ type = SubtitleType.ViPlaySubtitleFile;
+ mode = SubtitleMode.Times;
+ extensions = new string[] { "vsf" };
+ lineBreak = "|";
+
+ format = @"\{\* VIPLAY SUBTITLE FILE \*\}\s*\d+:\d+:\d+,\d+\s*-\s*\d+:\d+:\d+,\d+=.+";
+
+ subtitleIn = @"(?<StartHours>\d+)\s*:\s*(?<StartMinutes>\d+)\s*:\s*(?<StartSeconds>\d+)\s*,\s*(?<StartMilliseconds>\d+)\s*-\s*(?<EndHours>\d+)\s*:\s*(?<EndMinutes>\d+)\s*:\s*(?<EndSeconds>\d+)\s*,\s*(?<EndMilliseconds>\d+)\s*=\s*(?<Text>.*)";
+
+ subtitleOut = "<<StartHours>>:<<StartMinutes>>:<<StartSeconds>>,<<StartMilliseconds>>-" +
+ "<<EndHours>>:<<EndMinutes>>:<<EndSeconds>>,<<EndMilliseconds>>=<<Text>>\n";
+
+ bodyBeginOut = "{* VIPLAY SUBTITLE FILE *}";
+
+ }
+
+ internal override string StyleToString (Style style) {
+ string styleText = String.Empty;
+ if (style.Underline)
+ styleText += "<u>";
+ if (style.Bold)
+ styleText += "<b>";
+ if (style.Italic)
+ styleText += "<i>";
+ return styleText;
+ }
+
+ // can be optimized
+ internal override void SubtitleInputPostProcess (Subtitle subtitle) {
+ string subtitleText = subtitle.Text.Get(lineBreak);
+ string styleText = String.Empty;
+ MatchCollection matches = styleExpression.Matches(subtitleText);
+ foreach (Match match in matches) {
+ styleText += match.Value;
+ }
+ Style style = StringToStyle(styleText);
+ subtitle.Style = style;
+ subtitleText = styleExpression.Replace(subtitleText, String.Empty);
+ subtitle.Text.Set(subtitleText, lineBreak, true);
+ }
+
+}
+
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]