Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6348193
Showing
173 changed files
with
39,224 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
//--------------------------------------------------------------------------- | ||
/* | ||
TVP2 ( T Visual Presenter 2 ) A script authoring tool | ||
Copyright (C) 2000 W.Dee <dee@kikyou.info> and contributors | ||
See details of license at "license.txt" | ||
*/ | ||
//--------------------------------------------------------------------------- | ||
// Character code conversion | ||
//--------------------------------------------------------------------------- | ||
#include "tjsCommHead.h" | ||
|
||
#include "CharacterSet.h" | ||
|
||
//--------------------------------------------------------------------------- | ||
static tjs_int inline TVPWideCharToUtf8(tjs_char in, char * out) | ||
{ | ||
// convert a wide character 'in' to utf-8 character 'out' | ||
if (in < (1<< 7)) | ||
{ | ||
if(out) | ||
{ | ||
out[0] = (char)in; | ||
} | ||
return 1; | ||
} | ||
else if(in < (1<<11)) | ||
{ | ||
if(out) | ||
{ | ||
out[0] = (char)(0xc0 | (in >> 6)); | ||
out[1] = (char)(0x80 | (in & 0x3f)); | ||
} | ||
return 2; | ||
} | ||
else if(in < (1<<16)) | ||
{ | ||
if(out) | ||
{ | ||
out[0] = (char)(0xe0 | (in >> 12)); | ||
out[1] = (char)(0x80 | ((in >> 6) & 0x3f)); | ||
out[2] = (char)(0x80 | (in & 0x3f)); | ||
} | ||
return 3; | ||
} | ||
else if(in < (1<<21)) | ||
{ | ||
if(out) | ||
{ | ||
out[0] = (char)(0xf0 | (in >> 18)); | ||
out[1] = (char)(0x80 | ((in >> 12) & 0x3f)); | ||
out[2] = (char)(0x80 | ((in >> 6 ) & 0x3f)); | ||
out[3] = (char)(0x80 | (in & 0x3f)); | ||
} | ||
return 4; | ||
} | ||
else if(in < (1<<26)) | ||
{ | ||
if(out) | ||
{ | ||
out[0] = (char)(0xf8 | (in >> 24)); | ||
out[1] = (char)(0x80 | ((in >> 16) & 0x3f)); | ||
out[2] = (char)(0x80 | ((in >> 12) & 0x3f)); | ||
out[3] = (char)(0x80 | ((in >> 6 ) & 0x3f)); | ||
out[4] = (char)(0x80 | (in & 0x3f)); | ||
} | ||
return 5; | ||
} | ||
else if(in < (1<<31)) | ||
{ | ||
if(out) | ||
{ | ||
out[0] = (char)(0xfc | (in >> 30)); | ||
out[1] = (char)(0x80 | ((in >> 24) & 0x3f)); | ||
out[2] = (char)(0x80 | ((in >> 18) & 0x3f)); | ||
out[3] = (char)(0x80 | ((in >> 12) & 0x3f)); | ||
out[4] = (char)(0x80 | ((in >> 6 ) & 0x3f)); | ||
out[5] = (char)(0x80 | (in & 0x3f)); | ||
} | ||
return 6; | ||
} | ||
|
||
return -1; | ||
} | ||
//--------------------------------------------------------------------------- | ||
tjs_int TVPWideCharToUtf8String(const tjs_char *in, char * out) | ||
{ | ||
// convert input wide string to output utf-8 string | ||
int count = 0; | ||
while(*in) | ||
{ | ||
tjs_int n; | ||
if(out) | ||
{ | ||
n = TVPWideCharToUtf8(*in, out); | ||
out += n; | ||
} | ||
else | ||
{ | ||
n = TVPWideCharToUtf8(*in, NULL); | ||
/* | ||
in this situation, the compiler's inliner | ||
will collapse all null check parts in | ||
TVPWideCharToUtf8. | ||
*/ | ||
} | ||
if(n == -1) return -1; // invalid character found | ||
count += n; | ||
in++; | ||
} | ||
return count; | ||
} | ||
//--------------------------------------------------------------------------- | ||
static bool inline TVPUtf8ToWideChar(const char * & in, tjs_char *out) | ||
{ | ||
// convert a utf-8 charater from 'in' to wide charater 'out' | ||
const unsigned char * & p = (const unsigned char * &)in; | ||
if(p[0] < 0x80) | ||
{ | ||
if(out) *out = (tjs_char)in[0]; | ||
in++; | ||
return true; | ||
} | ||
else if(p[0] < 0xc2) | ||
{ | ||
// invalid character | ||
return false; | ||
} | ||
else if(p[0] < 0xe0) | ||
{ | ||
// two bytes (11bits) | ||
if((p[1] & 0xc0) != 0x80) return false; | ||
if(out) *out = ((p[0] & 0x1f) << 6) + (p[1] & 0x3f); | ||
in += 2; | ||
return true; | ||
} | ||
else if(p[0] < 0xf0) | ||
{ | ||
// three bytes (16bits) | ||
if((p[1] & 0xc0) != 0x80) return false; | ||
if((p[2] & 0xc0) != 0x80) return false; | ||
if(out) *out = ((p[0] & 0x1f) << 12) + ((p[1] & 0x3f) << 6) + (p[2] & 0x3f); | ||
in += 3; | ||
return true; | ||
} | ||
else if(p[0] < 0xf8) | ||
{ | ||
// four bytes (21bits) | ||
if((p[1] & 0xc0) != 0x80) return false; | ||
if((p[2] & 0xc0) != 0x80) return false; | ||
if((p[3] & 0xc0) != 0x80) return false; | ||
if(out) *out = ((p[0] & 0x07) << 18) + ((p[1] & 0x3f) << 12) + | ||
((p[2] & 0x3f) << 6) + (p[3] & 0x3f); | ||
in += 4; | ||
return true; | ||
} | ||
else if(p[0] < 0xfc) | ||
{ | ||
// five bytes (26bits) | ||
if((p[1] & 0xc0) != 0x80) return false; | ||
if((p[2] & 0xc0) != 0x80) return false; | ||
if((p[3] & 0xc0) != 0x80) return false; | ||
if((p[4] & 0xc0) != 0x80) return false; | ||
if(out) *out = ((p[0] & 0x03) << 24) + ((p[1] & 0x3f) << 18) + | ||
((p[2] & 0x3f) << 12) + ((p[3] & 0x3f) << 6) + (p[4] & 0x3f); | ||
in += 5; | ||
return true; | ||
} | ||
else if(p[0] < 0xfe) | ||
{ | ||
// six bytes (31bits) | ||
if((p[1] & 0xc0) != 0x80) return false; | ||
if((p[2] & 0xc0) != 0x80) return false; | ||
if((p[3] & 0xc0) != 0x80) return false; | ||
if((p[4] & 0xc0) != 0x80) return false; | ||
if((p[5] & 0xc0) != 0x80) return false; | ||
if(out) *out = ((p[0] & 0x01) << 30) + ((p[1] & 0x3f) << 24) + | ||
((p[2] & 0x3f) << 18) + ((p[3] & 0x3f) << 12) + | ||
((p[4] & 0x3f) << 6) + (p[5] & 0x3f); | ||
in += 6; | ||
return true; | ||
} | ||
return false; | ||
} | ||
//--------------------------------------------------------------------------- | ||
tjs_int TVPUtf8ToWideCharString(const char * in, tjs_char *out) | ||
{ | ||
// convert input utf-8 string to output wide string | ||
int count = 0; | ||
while(*in) | ||
{ | ||
tjs_char c; | ||
if(out) | ||
{ | ||
if(!TVPUtf8ToWideChar(in, &c)) | ||
return -1; // invalid character found | ||
*out++ = c; | ||
} | ||
else | ||
{ | ||
if(!TVPUtf8ToWideChar(in, NULL)) | ||
return -1; // invalid character found | ||
} | ||
count ++; | ||
} | ||
return count; | ||
} | ||
//--------------------------------------------------------------------------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//--------------------------------------------------------------------------- | ||
/* | ||
TVP2 ( T Visual Presenter 2 ) A script authoring tool | ||
Copyright (C) 2000 W.Dee <dee@kikyou.info> and contributors | ||
See details of license at "license.txt" | ||
*/ | ||
//--------------------------------------------------------------------------- | ||
// Character code conversion | ||
//--------------------------------------------------------------------------- | ||
|
||
#ifndef __CharacterSet_H__ | ||
#define __CharacterSet_H__ | ||
|
||
// various character conding conversion. | ||
// currently only utf-8 related functions are implemented. | ||
#include "tjsTypes.h" | ||
|
||
|
||
TJS_EXP_FUNC_DEF(tjs_int, TVPWideCharToUtf8String, (const tjs_char *in, char * out)); | ||
TJS_EXP_FUNC_DEF(tjs_int, TVPUtf8ToWideCharString, (const char * in, tjs_char *out)); | ||
|
||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* this file contains the actual definitions of */ | ||
/* the IIDs and CLSIDs */ | ||
|
||
/* link this file in with the server and any clients */ | ||
|
||
|
||
/* File created by MIDL compiler version 5.01.0164 */ | ||
/* at Tue Oct 03 00:37:04 2000 | ||
*/ | ||
/* Compiler settings for tvpsnd.idl: | ||
Os (OptLev=s), W1, Zp8, env=Win32, ms_ext, c_ext | ||
error checks: allocation ref bounds_check enum stub_data | ||
*/ | ||
//@@MIDL_FILE_HEADING( ) | ||
#ifdef __cplusplus | ||
extern "C"{ | ||
#endif | ||
|
||
|
||
#ifndef __IID_DEFINED__ | ||
#define __IID_DEFINED__ | ||
|
||
typedef struct _IID | ||
{ | ||
unsigned long x; | ||
unsigned short s1; | ||
unsigned short s2; | ||
unsigned char c[8]; | ||
} IID; | ||
|
||
#endif // __IID_DEFINED__ | ||
|
||
#ifndef CLSID_DEFINED | ||
#define CLSID_DEFINED | ||
typedef IID CLSID; | ||
#endif // CLSID_DEFINED | ||
|
||
const IID LIBID_TVPSndSysLib = {0xF09B2E87,0x740A,0x4AEA,{0x90,0xCB,0xAE,0x1C,0x4E,0xFD,0x35,0xF1}}; | ||
|
||
|
||
const IID IID_ITSSMediaBaseInfo = {0xB4C4239B,0x7D27,0x43CC,{0x85,0x23,0x66,0x95,0x5B,0xDF,0x59,0xDF}}; | ||
|
||
|
||
const IID IID_ITSSStorageProvider = {0x7DD61993,0x615D,0x481D,{0xB0,0x60,0xA9,0xFD,0x48,0x39,0x44,0x30}}; | ||
|
||
|
||
const IID IID_ITSSModule = {0xA938D1A5,0x2980,0x498B,{0xB0,0x51,0x99,0x93,0x1D,0x41,0x89,0x5D}}; | ||
|
||
|
||
const IID IID_ITSSWaveDecoder = {0x313864E2,0x910E,0x496F,{0x8A,0x6D,0x43,0x46,0x5C,0x10,0x5B,0x58}}; | ||
|
||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
Oops, something went wrong.