Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
surrogate-pair
Advanced tools
surrogate-pair.js is a library which makes handling surrogate pair easy.
if you load surrogate-pair.js, a global object named 'sp' is created. this object has utility methods below:
count code points of given string and return it.
sp.countCodePoints(''); // = 0
sp.countCodePoints('abc'); // = 3
sp.countCodePoints('あ'); // = 1
sp.countCodePoints('あ'); // = 1
'𠮟'.length; // = 2
sp.countCodePoints('𠮟'); // = 1
returns the code points in a string beginning at the specified location through the specified number of code points. this method resembles String.prototype.substr, but its startCodePoints should be positive number.
sp.substr('abc', 0); // = 'abc'
sp.substr('abc', 1); // = 'bc'
sp.substr('abc', 0, 0); // = ''
sp.substr('a𠮟', 0, 2); // = 'a𠮟'
sp.substr('a𠮟', 1, 1); // = '𠮟'
return true if given string contains any surrogate pair.
sp.findSurrogatePair(''); // = false
sp.findSurrogatePair('abc'); // = false
sp.findSurrogatePair('あ'); // = false
sp.findSurrogatePair('𠮟'); // = true
return true if given character code is high(leading) surrogate.
sp.checkHighSurrogate('a'.charCodeAt(0)) // = false
sp.checkHighSurrogate('𠮟'.charCodeAt(0)) // = true
sp.checkHighSurrogate('𠮟'.charCodeAt(1)) // = false
return true if given character code is low(trailing) surrogate.
sp.checkLowSurrogate('a'.charCodeAt(0)) // = false
sp.checkLowSurrogate('𠮟'.charCodeAt(0)) // = false
sp.checkLowSurrogate('𠮟'.charCodeAt(1)) // = true
Copyright 2011 Kengo TODA
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
we use QUnit for unit testing. http://docs.jquery.com/QUnit
surrogate-pair.min.js is compressed by YUI-compressor-2.4.6. http://developer.yahoo.com/yui/compressor/
surrogate-pair.js is written in coffeescript. http://jashkenas.github.com/coffee-script/
FAQs
a library to handle surrogate pair of UTF-16
The npm package surrogate-pair receives a total of 5 weekly downloads. As such, surrogate-pair popularity was classified as not popular.
We found that surrogate-pair demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.