1、WideString和String的区别在哪?
2、WideString常用在哪里?比如网址还是哪里~

解决方案 »

  1.   

    Unicode,多语言时候,
    接口,com,
      

  2.   

    举个简单的例子:统计中英文混合的字符串的字数。用string的话,要中英文分开统计,比较麻烦。
    如果直接用WideString,可以直接用Length(Str)
      

  3.   

    非常感谢,除了统计的时候,WideString一般还用在哪比较多?
    假如我们做一个浏览器,那地址栏的的Text我们要不要转换成WideString格式?
      

  4.   

    编码不一样
    比如string中的汉字,是国标码.WideString中的就是unicode编码我觉得地址栏的Text没必要用WideString吧
      

  5.   

    Type        Maximum length     Memory required Used for
    ShortString 255 characters     2 to 256 bytes backward compatibility
    AnsiString ~2^31 characters    4 bytes to 2GB 8-bit (ANSI) characters, DBCS 
                                                            ANSI, MBCS ANSI, etc.
    WideString ~2^30 characters    4 bytes to 2GB Unicode characters; multi-user servers 
                                                            and multi-language applications
    ShortString 向下兼容以前版本的。AnsiString, sometimes called the long string, is the preferred type for most purposes.
    String types can be mixed in assignments and expressions; the compiler automatically performs required conversions. But strings passed by reference to a function or procedure (as var and out parameters) must be of the appropriate type. Strings can be explicitly cast to a different string type (see Typecasts).
    The reserved word string functions like a generic type identifier. For example,var S: string;creates a variable S that holds a string. In the default {$H+} state, the compiler interprets string (when it appears without a bracketed number after it) as AnsiString. Use the {$H-} directive to turn string into ShortString.The standard function Length returns the number of characters in a string. The SetLength procedure adjusts the length of a string.Comparison of strings is defined by the ordering of the characters in corresponding positions. Between strings of unequal length, each character in the longer string without a corresponding character in the shorter string takes on a greater-than value. For example, "AB" is greater than "A"; that is, 'AB' > 'A' returns True. Zero-length strings hold the lowest values.You can index a string variable just as you would an array. If S is a string variable and i an integer expression, S[i] represents the ith character--or, strictly speaking, the ith byte--in S. For a ShortString or AnsiString, S[i] is of type AnsiChar; for a WideString, S[i] is of type WideChar. For single-byte (Western) locales, MyString[2] := 'A'; assigns the value A to the second character of MyString. The following code uses the standard AnsiUpperCase function to convert MyString to uppercase.