Browse Source

Cleanups.

Mark Sibly 9 years ago
parent
commit
56d808fea9

+ 10 - 11
modules/std/memory/databuffer.monkey2

@@ -263,7 +263,7 @@ Class DataBuffer Extends std.resource.Resource
 	
 	If `count` is omitted, all bytes from `offset` until the end of the data buffer are read.
 	
-	`encoding` should be one of "utf8" or "ascii".
+	`encoding` should be one of "utf8" or "ansi".
 
 	@param offset Byte offset to read the string.
 	
@@ -280,11 +280,10 @@ Class DataBuffer Extends std.resource.Resource
 	
 	Method PeekString:String( offset:Int,count:Int,encoding:String="utf8" )
 		DebugAssert( offset>=0 And count>=0 And offset+count<=_length )
-		DebugAssert( encoding="utf8" Or encoding="ascii" )
-		
-		If encoding="utf8" Return String.FromUtf8Data( _data+offset,count )
+
+		If encoding="ansi" Or encoding="ascii" Return String.FromAsciiData( _data+offset,count )
 		
-		Return String.FromAsciiData( _data+offset,count )
+		Return String.FromUtf8Data( _data+offset,count )
 	End
 	
 	#rem monkeydoc Writes a byte to the databuffer
@@ -427,7 +426,7 @@ Class DataBuffer Extends std.resource.Resource
 
 	#rem monkeydoc Write a string to the databuffer.
 
-	`encoding` should be one of "utf8" or "ascii".
+	`encoding` should be one of "utf8" or "ansi".
 	
 	If there is not enough room in the data buffer, the string data is truncated.
 	
@@ -443,14 +442,14 @@ Class DataBuffer Extends std.resource.Resource
 		
 		DebugAssert( encoding="utf8" Or encoding="ascii" )
 		
-		If encoding="utf8"
-			Local count:=value.Utf8Length
-			If offset+count>_length count=_length-offset
-			value.ToUtf8String( _data+offset,count )
-		Else
+		If encoding="ansi" Or encoding="ascii"
 			Local count:=value.Length
 			If offset+count>_length count=_length-offset
 			value.ToCString( _data+offset,count )
+		Else
+			Local count:=value.Utf8Length
+			If offset+count>_length count=_length-offset
+			value.ToUtf8String( _data+offset,count )
 		Endif
 
 	End

+ 1 - 1
modules/std/socket/socket.monkey2

@@ -150,7 +150,7 @@ Struct Socket
 	
 	Returns a closed socket upon failue.
 	
-	@Return A new socket.
+	@return A new socket.
 	
 	#end	
 	Function Connect:Socket( hostname:String,service:String )

+ 6 - 2
modules/std/stream/stream.monkey2

@@ -301,6 +301,8 @@ Class Stream
 	
 	#rem monkeydoc Reads a null terminated string from the stream.
 	
+	@param encoding The string encoding, "utf8" or "ansi".
+	
 	@return the string read.
 	
 	#end
@@ -311,8 +313,10 @@ Class Stream
 			If Not chr Exit
 			buf.Push( chr )
 		Wend
-		If encoding="utf8" Return String.FromUtf8Data( buf.Data.Data,buf.Length )
-		Return String.FromAsciiData( buf.Data.Data,buf.Length )
+		
+		If encoding="ansi" Or encoding="ascii" Return String.FromAsciiData( buf.Data.Data,buf.Length )
+		
+		Return String.FromUtf8Data( buf.Data.Data,buf.Length )
 	End
 	
 	#rem monkeydoc Writes a byte to the stream.