Get string length, character length, byte length

Source: Internet
Author: User

Metric Fast Development platform There is a Len in the base function that gets the character length function. The specific usage is:
len ("123ABC string")

The result of this method is: 9

that is, the total number of characters, without distinguishing between single-byte and double-byte cases.

If a field is set to a length of 9, then this string is saved to the database, it will prompt the string is too long, because the database is generally determined by the length of bytes.

in the Metric rapid development platform, there is no direct supply of this get string byte length function. The user wants to know how many bytes the string occupies and how to get it in the platform?

we know that the metric rapid development platform is a perfect combination of C #, and if two of times developers need similar functionality in their use, then they can find answers directly from C #.
there is a static method in C # that gets the length of the string bytes. static methods of C # can be used directly in the platform.
System.Text.Encoding.Default.GetBytes (String). Length
Example:
The byte length. value= System.Text.Encoding.Default.GetBytes (Text input box 1. Value). Length
The character length. value= len (Text input box 1. Value)

650) this.width=650; "id=" aimg_1664 "src=" http://bbs.delit.cn/data/attachment/forum/201606/15/ 142013h8z7sssd4682m4xe.png.thumb.jpg "width=" 399 "height=" 129 "alt=" 142013h8z7sssd4682m4xe.png.thumb.jpg "/>
other similar:
' Get the local computer name
MsgBox(System.Environment.MachineName)
' Get local computer users
MsgBox(System.Environment.UserName)


Original address: http://bbs.delit.cn/thread-1065-1-1.html

Reprint please specify the source:

Author: metric Technology http://www.delit.cn

Get string length, character length, byte length

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.