Index: trunk/Include/basic/function.sbp
===================================================================
--- trunk/Include/basic/function.sbp	(revision 394)
+++ trunk/Include/basic/function.sbp	(revision 400)
@@ -263,4 +263,5 @@
 				If _System_IsLowSurrogate(s[0]) Then
 					AscW = ((s[0] And &h3FF) As DWord << 10) Or (s[1] And &h3FF)
+					AscW += &h10000
 					Exit Function
 				End If
@@ -276,4 +277,5 @@
 		Return New String(c As StrChar, 1)
 	ElseIf c <= &h10FFFF Then
+		c -= &h10000
 		Dim t[1] As WCHAR
 		t[0] = (&hD800 Or (c >> 10)) As WCHAR
@@ -647,5 +649,5 @@
 	Val=0
 
-	While buf[0]=Asc(" ") or buf[0]=Asc(Ex"\t")
+	While ActiveBasic.CType.IsSpace(buf[0])
 		buf = VarPtr(buf[1])
 	Wend
@@ -655,5 +657,5 @@
 		temporary = temporary.ToUpper()
 		TempPtr = StrPtr(temporary)
-		If TempPtr(1)=Asc("O") Then
+		If TempPtr(1) = Asc("O") Then
 			'8進数
 			i=2
@@ -715,11 +717,8 @@
 
 Function Eof(FileNum As Long) As Long
-	Dim dwCurrent As DWord, dwEnd As DWord
-
 	FileNum--
-
-	dwCurrent=SetFilePointer(_System_hFile(FileNum),0,NULL,FILE_CURRENT)
-	dwEnd=SetFilePointer(_System_hFile(FileNum),0,NULL,FILE_END)
-	SetFilePointer(_System_hFile(FileNum),dwCurrent,NULL,FILE_BEGIN)
+	Dim dwCurrent = SetFilePointer(_System_hFile(FileNum), 0,NULL, FILE_CURRENT)
+	Dim dwEnd = SetFilePointer(_System_hFile(FileNum), 0, NULL, FILE_END)
+	SetFilePointer(_System_hFile(FileNum), dwCurrent, NULL, FILE_BEGIN)
 
 	If dwCurrent>=dwEnd Then
@@ -770,9 +769,9 @@
 
 Function _System_malloc(stSize As SIZE_T) As VoidPtr
-	Return HeapAlloc(_System_hProcessHeap,0,stSize)
+	Return HeapAlloc(_System_hProcessHeap, 0, stSize)
 End Function
 
 Function _System_calloc(stSize As SIZE_T) As VoidPtr
-	Return HeapAlloc(_System_hProcessHeap,HEAP_ZERO_MEMORY,stSize)
+	Return HeapAlloc(_System_hProcessHeap, HEAP_ZERO_MEMORY, stSize)
 End Function
 
@@ -786,5 +785,5 @@
 
 Sub _System_free(lpMem As VoidPtr)
-	HeapFree(_System_hProcessHeap,0,lpMem)
+	HeapFree(_System_hProcessHeap, 0, lpMem)
 End Sub
 
