简体   繁体   中英

Representing data types e.g. Chars, Strings, Integers etc

I am a .NET Developer and I do not believe I know enough about encoding. I have read this article: http://www.joelonsoftware.com/articles/Unicode.html .

Say I declare this string:

Dim TestString As String = "1"

I believe this will be represented as a Unicode character. Say I declare this integer:

Dim TestInt As Integer = 1

How is this represented? I assume that Unicode is not used? ie it is only used for String and Chars? Is that correct? Therefore I believe that on a 32 bit machine 1 would simply be represented as:

00000000 0000000 0000000 00000001

Do numeric data types have byte order marks: http://en.wikipedia.org/wiki/Byte_order_mark ?

All strings in .NET are UTF-16. From the language spec:

Visual Basic .NET defines the following primitive types:
...

  • The Char value type, which represents a single Unicode character and maps to System.Char...
  • The String reference type, which represents a sequence of Unicode characters and maps to System.String...

Why should an integral value types like an integer be represented with Unicode in computer memory? Unicode is (citing from Wikipedia ):

a computing industry standard for the consistent encoding, representation and handling of text expressed in most of the world's writing systems.

So yes, it's only used for Strings and Chars.

Also note that an Integer will always be 4-byte signed integer, no matter if you use a 32 bit or 64 bit machine.

Byte order marks are an entire different topic. As already said in a comment, it's used in text file or stream.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM