mirror of
				https://github.com/msgpack/msgpack-c.git
				synced 2025-10-27 11:06:51 +01:00 
			
		
		
		
	csharp: fix char pack/unpack problem on Mono
This commit is contained in:
		| @@ -42,6 +42,11 @@ namespace msgpack | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		public void Write (char x) | ||||
| 		{ | ||||
| 			Write ((ushort)x); | ||||
| 		} | ||||
|  | ||||
| 		public void Write (uint x) | ||||
| 		{ | ||||
| 			if (x < 0x10000) { | ||||
|   | ||||
| @@ -61,7 +61,8 @@ namespace msgpack | ||||
| 				else if (t.Equals (typeof (byte))) writer.Write ((byte)o); | ||||
| 				else if (t.Equals (typeof (sbyte))) writer.Write ((sbyte)o); | ||||
| 				else if (t.Equals (typeof (short))) writer.Write ((short)o); | ||||
| 				else if (t.Equals (typeof (ushort)) || t.Equals (typeof (char))) writer.Write ((ushort)o); | ||||
| 				else if (t.Equals (typeof (ushort))) writer.Write ((ushort)o); | ||||
| 				else if (t.Equals (typeof (char))) writer.Write ((ushort)(char)o); | ||||
| 				else throw new NotSupportedException (); | ||||
| 				return; | ||||
| 			} | ||||
| @@ -113,6 +114,26 @@ namespace msgpack | ||||
| 			return (T)Unpack (reader, typeof (T)); | ||||
| 		} | ||||
|  | ||||
| 		public object Unpack (Type type, byte[] buf) | ||||
| 		{ | ||||
| 			return Unpack (type, buf, 0, buf.Length); | ||||
| 		} | ||||
|  | ||||
| 		public object Unpack (Type type, byte[] buf, int offset, int size) | ||||
| 		{ | ||||
| 			using (MemoryStream ms = new MemoryStream (buf, offset, size)) { | ||||
| 				return Unpack (type, ms); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		public object Unpack (Type type, Stream strm) | ||||
| 		{ | ||||
| 			if (type.IsPrimitive) | ||||
| 				throw new NotSupportedException (); | ||||
| 			MsgPackReader reader = new MsgPackReader (strm); | ||||
| 			return Unpack (reader, type); | ||||
| 		} | ||||
|  | ||||
| 		object Unpack (MsgPackReader reader, Type t) | ||||
| 		{ | ||||
| 			if (t.IsPrimitive) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Kazuki Oikawa
					Kazuki Oikawa