Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Get string length, character length, byte length

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

In the basic function of Metrics Rapid Development platform, there is a len function to obtain character length. The specific usage is:

Len ("123Abc string")

The result of this method is: 9

That is, the total number of characters, there is no distinction between single-byte and double-byte cases.

If a field is set to a length of 9, when the string is saved to the database, it will be prompted that the string is too long, because the database is generally judged by the byte length.

In the metric rapid development platform, this function to obtain the string byte length is not provided directly. The user wants to know how many bytes this string takes up and how to get it on the platform.

We know that the metrics rapid development platform is perfectly combined with c #, and if secondary developers need similar features in use, they can find the answer directly from c #.

There is a static method in C # that is to get the string byte length. The static method of c # can be used directly in the platform.

System.Text.Encoding.Default.GetBytes (string) .Length

Example:

Byte length .value = System.Text.Encoding.Default.GetBytes (text input box 1.Value) .Length

Character length .value = len (text input box 1.Value)

Others are similar:

'get the local computer name

Msgbox (System.Environment.MachineName)

'get the local computer user

Msgbox (System.Environment.UserName)

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

Please indicate the source of the reprint:

Written by: measurement Technology http://www.delit.cn

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report