


This time I will bring you the method of dynamically obtaining the number of bytes and characters of the current input content, and dynamically obtaining the number of bytes and characters of the current input content. What are the precautions?. The following is a practical case. Get up and take a look.
Detailed example of dynamically counting the number of bytes and characters of the current input content
I saw that there are many methods using charAt on the Internet. The principle is also very simple. Use regular expressions to determine whether it is Chinese. If so, add 2 to the number of bytes. If not, add 1 to the number of bytes.
Later I found another way. Since one Chinese character corresponds to two bytes, you can use regular rules to replace the matched Chinese character with two characters, for example: "xx", and finally get the converted string## The length of # is the number of bytes.
The number of characters corresponds to how many Chinese characters, letters, and symbols there are.//短信内容字数 $scope.bytesCount= 0; $scope.smsLength = 0; $scope.smsContent = '1'; $scope.smsCount = function () { $scope.bytesCount = $scope.smsContent.replace(/[^\x00-\xff]/g, 'xx').length; $scope.smsLength = $scope.smsContent.length; }I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website! Recommended reading:
Double linked list definition of JS data structure
The above is the detailed content of Dynamically obtain the number of bytes and characters of the current input content. For more information, please follow other related articles on the PHP Chinese website!

特别是在过去十年中,移动设备已成为与朋友和家人分享内容的主要方式。易于访问、易于使用的界面以及实时捕获图像和视频的能力使其成为制作和共享内容的绝佳选择。但是,恶意用户很容易滥用这些工具来转发不需要的敏感内容,这些内容可能不适合查看并未经您的同意。为了防止此类情况发生,iOS17中引入了带有“敏感内容警告”的新功能。让我们来看看它以及如何在iPhone上使用它。新的“敏感内容警告”是什么,它是如何工作的?如上所述,敏感内容警告是一项新的隐私和安全功能,旨在帮助防止用户查看敏感内容,包括iPhone

怎么更改MicrosoftEdge浏览器打开是360导航的页面呢?其实很简单,那么现在小编就和大家一起分享关于更改MicrosoftEdge浏览器打开是360导航页面的方法,有需要的朋友可以来看看哦,希望可以帮助到大家。打开MicrosoftEdge浏览器。我们看到是下图这种页面。点击右上角的三点图标。点击“设置”。在设置页面的左侧栏里点击“启动时”。点击右侧栏里的图中示意的三点(不要能点击“打开新标签页”),然后点击编辑,将网址改成“0”(或其他无意义的数字)。然后点击“保存”。接下来,选择“

大家知道MicrosoftEdge在哪设置显示下载按钮吗?下文小编就带来了MicrosoftEdge设置显示下载按钮的方法,希望对大家能够有所帮助,一起跟着小编来学习一下吧!第一步:首先打开MicrosoftEdge浏览器,单击右上角【...】标识,如下图所示。第二步:然后在弹出菜单中,单击【设置】,如下图所示。第三步:接着单击界面左侧【外观】,如下图所示。第四步:最后单击【显示下载按钮】右侧按钮,由灰变蓝即可,如下图所示。上面就是小编为大家带来的MicrosoftEdge在哪设置显示下载按钮的

CheatEngine是一款游戏编辑器,能够对游戏的内存进行编辑修改。但是它的默认语言是非中文的,对于很多小伙伴来说比较不方便,那么CheatEngine怎么设置中文呢?今天小编就给大家详细介绍一下CheatEngine设置中文的方法,希望可以帮助到你。 设置方法一 1、双击打开软件,点击左上角的“edit”。 2、接着点击下方选项列表中的“settings”。 3、在打开的窗口界面中,点击左侧栏中的“languages”

时空中的绘旅人已经确定在2月29日更新之后,玩家可以和艾因一起去参加露天音乐节,获得与艾因的好感度加成,3月4日将会开启缱绻假日煦色韶光活动,玩家可以提升假日行程等级解锁全新短信和Lofter内容。时空中的绘旅人艾因的日常:常驻内容更新更新2月29日版本后,可体验全新校园日程[参加露天音乐节],跟艾因一起参与可获得好感度加成。3月4日09:30-4月15日05:00,在「缱绻假日·煦色韶光」活动期间提升[假日行程]等级到8级和28级,可分别解锁全新短信和Lofter内容。*新增短信、Lofter

问题陈述编写一个C程序,以空格分隔的整数作为数组输入。SampleExamples输入12345输出‘Arrayelementsare-’1,2,3,4,5Explanation的中文翻译为:解释输入包含5个以空格分隔的整数。输入997687542356878967343423输出‘Arrayelementsare-’99,76,87,54,23,56,878,967,34,34,23Explanation的中文翻译为:解释输入包含11个以空格分隔的整数。方法一在这种方法中,我们将把输入中的以空

来源:深潮TechFlow作为Solana生态中备受瞩目的新兴项目,Jupiter尽管推出时间不长,却已经在DeFi领域中迅速崭露头角。然而,即使在这样快速发展的环境中,经济模型的完善和代币价格的稳定仍然至关重要。缺乏这些支撑,项目很容易陷入恶性循环,最终可能导致其衰落甚至无法为自身维持生机。因此,Jupiter需要不断优化其经济设计,确保代币价格稳定性,以确保项目的长期发展和成功。Solana链在最近一周表现强劲,其代币SOL在二级市场上涨势如虹,而Jupiter的代币$JUP也在过去两周内涨

什么是PQ3协议?目前,通信安全由三个安全级别来衡量。级别0:在此级别中,邮件保持未加密状态。级别1:此处的消息是端到端加密的,但没有额外的身份验证或量子安全性。级别2:这包括身份验证和量子安全性,但它们仅限于初始密钥建立。这意味着,只有当对话密钥材料永远不会受到损害时,才能提供量子安全性。图片提供:Apple新的iMessage安全协议PQ3是首个被认定为达到Apple所谓的“3级安全”的消息传递协议。该协议采用了量子加密技术,用于保护密钥生成和消息交换的安全性。即使密钥遭泄露,3级PQC也能


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!
