Get the App
SLTechnology News&Howtos  ›  Database  › 

Get string length, character length, byte length

Shulou Source: shulou.com Published: 2022-06-01 08:42:38 09月19日 Update

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

Tags: Character string byte length platform development function development platform method caching data database text user computer static input provenance function original text Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux NVidia OPPO Reno Microsoft vpn