Ignore:
Timestamp:
Mar 9, 2007, 10:15:34 PM (17 years ago)
Author:
イグトランス (egtra)
Message:

Environment, OperatingSystem, Versionの追加、Unicode対応修正ほか

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Include/basic/function.sbp

    r137 r142  
    344344'------------
    345345
    346 Function Asc(buf As *Char) As Char
     346Function Asc(buf As *StrChar) As StrChar
    347347    Asc = buf[0]
    348348End Function
    349349
    350 Function Chr$(code As Char) As String
     350Function Chr$(code As StrChar) As String
    351351    Chr$ = ZeroString(1)
    352352    Chr$[0] = code
    353353End Function
    354354
    355 #ifdef UNICODE
     355#ifndef __STRING_IS_NOT_UNICODE
    356356Function AscW(s As *WCHAR) As UCSCHAR
    357357    If s.Length = 0 Then
     
    487487
    488488    Mid$=ZeroString(ReadLength)
    489     memcpy(StrPtr(Mid$), VarPtr(buf[StartPos]), SizeOf (Char) * ReadLength)
     489    memcpy(StrPtr(Mid$), VarPtr(buf.Chars[StartPos]), SizeOf (Char) * ReadLength)
    490490End Function
    491491
     
    515515    If i>length Then
    516516        Right$=ZeroString(length)
    517         memcpy(StrPtr(Right$), VarPtr(buf[i-length]), SizeOf (Char) * length)
     517        memcpy(StrPtr(Right$), VarPtr(buf.Chars[i-length]), SizeOf (Char) * length)
    518518    Else
    519519        Right$=buf
     
    691691    Return MakeStr(buffer)
    692692End Function
    693 Function Str$(value As LONG_PTR) As String
     693Function Str$(value As Int64) As String
    694694    Dim temp[255] As Char
    695 #ifdef _WIN64
    696695    _sntprintf(temp, Len (temp) \ SizeOf (Char), "%I64d", value)
    697 #else
    698     _sntprintf(temp, Len (temp) \ SizeOf (Char), "%d", value)
    699 #endif
    700696    Str$ = temp
    701697End Function
     
    881877
    882878Function Lof(FileNum As Long) As Long
    883     Lof=GetFileSize(_System_hFile(FileNum-1),NULL)
     879    Lof = GetFileSize(_System_hFile(FileNum-1), 0)
    884880End Function
    885881
     
    10591055End Function
    10601056
     1057'--------
     1058' 文字列関数その2
     1059'--------
    10611060Function _System_IsSurrogatePair(wcHigh As WCHAR, wcLow As WCHAR) As Boolean
    10621061    If &hD800 <= wcHigh And wcHigh < &hDC00 Then
     
    10681067End Function
    10691068
    1070 Function _System_IsDoubleUnitChar(lead As Char, trail As Char) As Boolean
    1071 #ifdef UNICODE
     1069Function _System_IsDoubleUnitChar(lead As WCHAR, trail As WCHAR) As Boolean
    10721070    Return _System_IsSurrogatePair(lead, trail)
    1073 #else
     1071End Function
     1072
     1073Function _System_IsDoubleUnitChar(lead As SByte, trail As SByte) As Boolean
    10741074    Return IsDBCSLeadByte(lead) <> FALSE
    1075 #endif
    1076 End Function
    1077 
    1078 Sub _System_FillChar(p As *Char, n As SIZE_T, c As Char)
     1075End Function
     1076
     1077Sub _System_FillChar(p As PWSTR, n As SIZE_T, c As WCHAR)
    10791078    Dim i As SIZE_T
    10801079    For i = 0 To ELM(n)
     
    10831082End Sub
    10841083
    1085 Function _System_ASCII_IsUpper(c As Char) As Boolean
     1084Sub _System_FillChar(p As PSTR, n As SIZE_T, c As SByte)
     1085    Dim i As SIZE_T
     1086    For i = 0 To ELM(n)
     1087        p[i] = c
     1088    Next
     1089End Sub
     1090
     1091Function _System_ASCII_IsUpper(c As WCHAR) As Boolean
    10861092    Return c As DWord - &h41 < 26 ' &h41 = Asc("A")
    10871093End Function
    10881094
     1095Function _System_ASCII_IsUpper(c As SByte) As Boolean
     1096    Return _System_ASCII_IsUpper(c As Byte As WCHAR)
     1097End Function
     1098
     1099Function _System_ASCII_IsLower(c As WCHAR) As Boolean
     1100    Return c As DWord - &h61 < 26 ' &h61 = Asc("a")
     1101End Function
     1102
    10891103Function _System_ASCII_IsLower(c As Char) As Boolean
    1090     Return c As DWord - &h61 < 26 ' &h61 = Asc("a")
    1091 End Function
    1092 
    1093 Function _System_ASCII_ToLower(c As Char) As Char
     1104    Return _System_ASCII_IsLower(c As Byte As WCHAR)
     1105End Function
     1106
     1107Function _System_ASCII_ToLower(c As WCHAR) As WCHAR
    10941108    If _System_ASCII_IsUpper(c) Then
    10951109        Return c Or &h20
     
    10971111        Return c
    10981112    End If
     1113End Function
     1114
     1115Function _System_ASCII_ToLower(c As SByte) As SByte
     1116    Return _System_ASCII_ToLower(c As Byte As WCHAR) As Byte As SByte
    10991117End Function
    11001118
     
    11071125End Function
    11081126
    1109 Function _System_WideCharToMultiByte(s As PCWSTR) As PSTR
    1110     Return _System_WideCharToMultiByte(s, lstrlenW(s) + 1, 0)
    1111 End Function
    1112 
    1113 Function _System_WideCharToMultiByte(s As PCWSTR, size As Long) As PSTR
    1114     Return _System_WideCharToMultiByte(s, size, 0)
    1115 End Function
    1116 
    1117 Function _System_WideCharToMultiByte(ws As PCWSTR, size As Long, flag As DWord) As PSTR
    1118     Dim sizeMBS = WideCharToMultiByte(CP_THREAD_ACP, flag, s, size, 0, 0, 0, 0)
    1119     Dim mbs = _System_malloc(sizeMBS) As PSTR
    1120     WideCharToMultiByte(CP_THREAD_ACP, flag, s, size, mbs, sizeMBS, 0, 0)
    1121     Return mbs
    1122 End Function
    1123 
    1124 Function _System_MultiByteToWideChar(s As PCSTR) As PWSTR
    1125     Return _System_MultiByteToWideChar(s, lstrlenA(s) + 1, 0)
    1126 End Function
    1127 
    1128 Function _System_MultiByteToWideChar(s As PCSTR, size As Long) As PWSTR
    1129     Return _System_MultiByteToWideChar(s, size, 0)
    1130 End Function
    1131 
    1132 Function _System_MultiByteToWideChar(s As PCSTR, size As Long, flag As DWord) As PWSTR
    1133     Dim sizeMBS = MultiByteToWideChar(CP_THREAD_ACP, flag, s, size, 0, 0)
    1134     Dim mbs = _System_malloc(SizeOf (WCHAR) * sizeMBS) As PWSTR
    1135     MultiByteToWideChar(CP_THREAD_ACP, flag, s, size, mbs, sizeMBS)
    1136     Return mbs
    1137 End Function
     1127Function _System_ASCII_ToUpper(c As SByte) As SByte
     1128    Return _System_ASCII_ToUpper(c As Byte As WCHAR) As Byte As SByte
     1129End Function
     1130
    11381131
    11391132Function _System_StrCmp(s1 As PCSTR, s2 As PCSTR) As Long
     
    11581151    _System_StrCmp = s1[i] - s2[i]
    11591152End Function
     1153
    11601154#endif '_INC_FUNCTION
Note: See TracChangeset for help on using the changeset viewer.