Comments (4)
Very interesting. Thanks for linking that PR so I could learn from your blog post (along with Wikipedia to learn why there are only 17 planes, rather than 256 like 2 hex digits would suggest).
I'm more than happy to use this logic in this library, given that it follows the RFC and is used in ical-generator, which this library relies on to generate iCal objects. Before I copy/paste your implementation in the linked PR, I've got a couple questions:
- What are the unicode boundaries you're checking in
if (ch >= '\ud800' && ch <= '\udbff')
(I didn't see anything in your post or wiki that would tip me off) - Why are you checking unicode value range rather than just checking length of the character like you do in your post (
'𝌆'.length == 2
) - Would you be open to making your function a standalone library? I feel like many CalDAV/iCal libraries would benefit from using the same octet checking, and your logic wouldn't just exist in two random libraries.
Thanks for your help.
from caldav-adapter.
Very interesting. Thanks for linking that PR so I could learn from your blog post
I am not the author of this blog post, I only learned form that.
- What are the unicode boundaries you're checking in
if (ch >= '\ud800' && ch <= '\udbff')
(I didn't see anything in your post or wiki that would tip me off)
The blog says "The first code unit of a surrogate pair is always in the range from 0xD800 to 0xDBFF".
- Why are you checking unicode value range rather than just checking length of the character like you do in your post (
'𝌆'.length == 2
)
'𝌆' is Unicode character. But in order to get a single Unicode character from a string, I cannot use string[offset]
or string.charAt(offset)
, because that gives me a Javascript character, which might just be the first of a surrogate pair. And to check whether this is the case, I check the Unicode value range. Makes sense?
- Would you be open to making your function a standalone library? I feel like many CalDAV/iCal libraries would benefit from using the same octet checking, and your logic wouldn't just exist in two random libraries.
Good idea, but it is probably more efficient if you or @sebbo2002 publish this library alongside your existing ones. I do not claim any copyright on these few lines of code.
from caldav-adapter.
Apologies, I should've checked the author before attributing it to you! Regardless, thank you for surfacing it to me.
The blog says "The first code unit of a surrogate pair is always in the range from 0xD800 to 0xDBFF".
Doh, that's why you shouldn't read HEX char codes late at night.
'𝌆' is Unicode character. But in order to get a single Unicode character from a string, I cannot use string[offset] or string.charAt(offset), because that gives me a Javascript character, which might just be the first of a surrogate pair. And to check whether this is the case, I check the Unicode value range. Makes sense?
Yes. If I have a string const str = abc𝌆ef
, str[3].length
will equal 1
because it's the Javascript character.
Good idea, but it is probably more efficient if you or @sebbo2002 publish this library alongside your existing ones. I do not claim any copyright on these few lines of code.
Sounds good. I'll include the code in this library for now, and keep an eye on whether @sebbo2002 himself decides to publish it separately or not. It may be too niche to really need to be an entirely separate package anyway.
from caldav-adapter.
@HeikoTheissen Published to npm
as version 4.1.0
. Thanks again for your contribution.
from caldav-adapter.
Related Issues (11)
- Which clients has this been tested with? HOT 2
- how to run? HOT 30
- ETag with Android HOT 4
- Allday events not working properly HOT 2
- Question: setting macOS HOT 1
- getEventsByDate seems to have not the correct response for iCal HOT 4
- xBuild multistatus handles empty responses incorrectly
- Webapp/Express framework support HOT 2
- CardDAV support HOT 2
- Tests and Compatibility Documentation (CardDAV/CalDAV RFC Support) HOT 26
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from caldav-adapter.