mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-02 16:22:40 -06:00
String docs addenum, OEM charset in GetEnv (thanks Zbigniew), BLOB in MySql (thanks Sergey)
git-svn-id: svn://ultimatepp.org/upp/trunk@1442 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
cd0d3d47f9
commit
29649cf062
5 changed files with 39 additions and 10 deletions
|
|
@ -6,13 +6,14 @@
|
|||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
|
||||
|
||||
String GetEnv(const char *id)
|
||||
{
|
||||
return FromSystemCharset(getenv(id));
|
||||
return FromOEMCharset(getenv(id));
|
||||
}
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
|
||||
String GetExeFilePath()
|
||||
{
|
||||
return GetModuleFileName();
|
||||
|
|
@ -26,6 +27,11 @@ String GetHomeDirectory() {
|
|||
|
||||
#ifdef PLATFORM_POSIX
|
||||
|
||||
String GetEnv(const char *id)
|
||||
{
|
||||
return FromSystemCharset(getenv(id));
|
||||
}
|
||||
|
||||
char Argv0__[_MAX_PATH + 1];
|
||||
|
||||
static void sSetArgv0__(const char *title)
|
||||
|
|
|
|||
|
|
@ -608,16 +608,26 @@ String ToSystemCharset(const String& src)
|
|||
return b;
|
||||
}
|
||||
|
||||
String FromSystemCharset(const String& src)
|
||||
String FromWin32Charset(const String& src, int cp)
|
||||
{
|
||||
WStringBuffer b(src.GetLength());
|
||||
int q = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, ~src, src.GetLength(), (WCHAR*)~b, src.GetLength());
|
||||
int q = MultiByteToWideChar(cp, MB_PRECOMPOSED, ~src, src.GetLength(), (WCHAR*)~b, src.GetLength());
|
||||
if(q <= 0)
|
||||
return src;
|
||||
b.SetCount(q);
|
||||
return WString(b).ToString();
|
||||
}
|
||||
|
||||
String FromOEMCharset(const String& src)
|
||||
{
|
||||
return FromWin32Charset(src, CP_OEMCP);
|
||||
}
|
||||
|
||||
String FromSystemCharset(const String& src)
|
||||
{
|
||||
return FromWin32Charset(src, CP_ACP);
|
||||
}
|
||||
|
||||
WString ToSystemCharsetW(const char *src)
|
||||
{
|
||||
return String(src).ToWString();
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ String FromSystemCharsetW(const wchar *src);
|
|||
#endif
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
String FromOEMCharset(const String& src);
|
||||
String GetErrorMessage(dword dwError);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -15,11 +15,17 @@ topic "String and WString";
|
|||
veable][@(0.0.255)3 <][*3 String][3 , ][_^AString^3 AString][@(0.0.255)3 <][_^String0^3 Strin
|
||||
g0][@(0.0.255)3 >][3 _>_]&]
|
||||
[s0;3%- &]
|
||||
[s0; String is a value class that contains an array of characters.
|
||||
It is designed to have fast copy operations. The array of characters
|
||||
is zero terminated. String provides non`-mutable access to the
|
||||
array of characters. String can store 8 bit encoded string or
|
||||
an Utf8 encoded string&]
|
||||
[s0; String is a value class that contains an array of characters
|
||||
(or bytes). It is designed to have fast copy operations. The
|
||||
array of characters is zero terminated. String provides non`-mutable
|
||||
access to the array of characters. String can store 8 bit encoded
|
||||
string or an UTF`-8 encoded string. For UTF`-8 strings, however,
|
||||
String works with raw 8 bit values `- there are not automatic
|
||||
conversions performed e.g. in operator`[`]. If you need to access
|
||||
individual UTF`-8 characters, the best practice in most cases
|
||||
is to convert it to WString (and eventually back after processing).&]
|
||||
[s0; &]
|
||||
[s0; String is also often used to store raw binary data.&]
|
||||
[s0; &]
|
||||
[s0; WString is similar to String, but it uses 16 bit Ucs2 encoding.
|
||||
String and WString share a number of common functions through
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@
|
|||
#define STRING_(x, n) COLUMN_(MySqlTextType(n), String, x, n, 0)
|
||||
#define STRING_ARRAY_(x, n, items) COLUMN_ARRAY_(MySqlTextType(n), String, x, n, 0, items)
|
||||
|
||||
#define BLOB(x) COLUMN("longblob", String, x, 0, 0)
|
||||
#define BLOB_(x) COLUMN_("longblob", String, x, 0, 0)
|
||||
|
||||
#define PRIMARY_KEY INLINE_ATTRIBUTE("primary key")
|
||||
#define AUTO_INCREMENT INLINE_ATTRIBUTE("auto_increment")
|
||||
#define KEY INLINE_ATTRIBUTE("key")
|
||||
|
|
@ -81,6 +84,9 @@
|
|||
#undef STRING_
|
||||
#undef STRING_ARRAY_
|
||||
|
||||
#undef BLOB
|
||||
#undef BLOB_
|
||||
|
||||
#undef PRIMARY_KEY
|
||||
#undef AUTO_INCREMENT
|
||||
#undef KEY
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue