Index: trunk/Include/basic/function.sbp
===================================================================
--- trunk/Include/basic/function.sbp	(revision 391)
+++ trunk/Include/basic/function.sbp	(revision 394)
@@ -243,5 +243,5 @@
 '------------
 
-Function Asc(buf As *StrChar) As StrChar
+Function Asc(buf As String) As StrChar
 	Asc = buf[0]
 End Function
@@ -253,9 +253,17 @@
 #ifndef __STRING_IS_NOT_UNICODE
 Function AscW(s As String) As UCSCHAR
-	If s.Length = 0 Then
+	If String.IsNullOrEmpty(s) Then
 		AscW = 0
-	Else
-		If _System_IsSurrogatePair(s[0], s[1]) Then
-			AscW = ((s[0] And &h3FF) As DWord << 10) Or (s[1] And &h3FF)
+		'ArgumentNullExceptionに変えるかも
+	Else
+		If _System_IsHighSurrogate(s[0]) Then
+			'有効なサロゲートペアになっていない場合には、
+			'例外を投げるようにしたほうがよいかもしれない。
+			If s.Length > 1 Then
+				If _System_IsLowSurrogate(s[0]) Then
+					AscW = ((s[0] And &h3FF) As DWord << 10) Or (s[1] And &h3FF)
+					Exit Function
+				End If
+			End If
 		Else
 			AscW = s[0]
@@ -267,9 +275,11 @@
 	If c <= &hFFFF Then
 		Return New String(c As StrChar, 1)
-	ElseIf c < &h10FFFF Then
-		Dim t[1] = [&hD800 Or (c >> 10), &hDC00 Or (c And &h3FF)] As WCHAR
+	ElseIf c <= &h10FFFF Then
+		Dim t[1] As WCHAR
+		t[0] = (&hD800 Or (c >> 10)) As WCHAR
+		t[1] = (&hDC00 Or (c And &h3FF)) As WCHAR
 		Return New String(t, 2)
 	Else
-		'ArgumentOutOfRangeException
+		Throw New System.ArgumentOutOfRangeException("ChrW: c is invalid Unicode code point.", "c")
 	End If
 End Function
@@ -691,5 +701,9 @@
 	Else
 		'10進数
+#ifdef __STRING_IS_NOT_UNICODE
 		sscanf(buf,"%lf",VarPtr(Val))
+#else
+		swscanf(buf,ToWCStr("%lf"),VarPtr(Val))
+#endif
 	End If
 End Function
@@ -917,11 +931,14 @@
 End Function
 
+Function _System_HashFromUInt(x As QWord) As Long
+	Return (HIDWORD(x) Xor LODWORD(x)) As Long
+End Function
+
+Function _System_HashFromUInt(x As DWord) As Long
+	Return x As Long
+End Function
+
 Function _System_HashFromPtr(p As VoidPtr) As Long
-#ifdef _WIN64
-	Dim qw = p As QWord
-	Return (HIDWORD(qw) Xor LODWORD(qw)) As Long
-#else
-	Return p As Long
-#endif
+	Return _System_HashFromUInt(p As ULONG_PTR)
 End Function
 
@@ -952,10 +969,18 @@
 '--------
 Function _System_IsSurrogatePair(wcHigh As WCHAR, wcLow As WCHAR) As Boolean
-	If &hD800 <= wcHigh And wcHigh < &hDC00 Then
-		If &hDC00 <= wcLow And wcLow < &hE000 Then
+	If _System_IsHighSurrogate(wcHigh) Then
+		If _System_IsLowSurrogate(wcLow) Then
 			Return True
 		End If
 	End If
 	Return False
+End Function
+
+Function _System_IsHighSurrogate(c As WCHAR) As Boolean
+	Return &hD800 <= c And c < &hDC00
+End Function
+
+Function _System_IsLowSurrogate(c As WCHAR) As Boolean
+	Return &hDC00 <= c And c < &hE000 
 End Function
 
