<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Tutorial on JsonKit Blog</title>
    <link>https://jsokit.com/blog/categories/tutorial/</link>
    <description>Recent content in Tutorial on JsonKit Blog</description>
    <generator>Hugo</generator>
    <language>en</language>
    <copyright>© 2025 JsonKit</copyright>
    <lastBuildDate>Tue, 12 May 2026 16:16:32 +0000</lastBuildDate>
    <atom:link href="https://jsokit.com/blog/categories/tutorial/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>XML Formatter: Building a Parser with State Machine</title>
      <link>https://jsokit.com/blog/posts/xml-formatter-building-a-parser-with-state-machine/</link>
      <pubDate>Tue, 12 May 2026 16:16:32 +0000</pubDate>
      <guid>https://jsokit.com/blog/posts/xml-formatter-building-a-parser-with-state-machine/</guid>
      <description>XML Formatter: Building a Parser with State Machine Dealing with minified XML from third-party APIs is painful. Most online tools are either bloated or can&amp;rsquo;t handle special nodes like CDATA and comments. So I built my own. Here&amp;rsquo;s how it works.&#xA;The Core: No Native API for XML Unlike JSON where JSON.parse + JSON.stringify does the job in two lines, XML has no native formatting API. You have to parse the string yourself, identify tags, attributes, and text content, then reformat.</description>
    </item>
    <item>
      <title>Word Counter: Unicode Handling and Regex Edge Cases in Mixed Chinese-English Text</title>
      <link>https://jsokit.com/blog/posts/word-counter-unicode-handling-and-regex-edge-cases-in-mixed-chinese-english-text/</link>
      <pubDate>Tue, 12 May 2026 15:16:32 +0000</pubDate>
      <guid>https://jsokit.com/blog/posts/word-counter-unicode-handling-and-regex-edge-cases-in-mixed-chinese-english-text/</guid>
      <description>Word Counter: Unicode Handling and Regex Edge Cases in Mixed Chinese-English Text Writing articles, tweets, documentation—you always need to count words. Many word counters exist, but when mixing Chinese and English, the results are often wrong. The culprit? Improper Unicode character handling and regex edge cases.&#xA;The Core Logic of Word Counting 1. Character Count Seems simple—just text.length, right? Not quite.&#xA;const text = &amp;#34;Hello 世界&amp;#34; console.log(text.length) // 8, correct But here&amp;rsquo;s the catch—Emoji and special characters:</description>
    </item>
    <item>
      <title>From Handshake to Heartbeat: Building a WebSocket Online Testing Tool</title>
      <link>https://jsokit.com/blog/posts/from-handshake-to-heartbeat-building-a-websocket-online-testing-tool/</link>
      <pubDate>Mon, 11 May 2026 16:42:42 +0000</pubDate>
      <guid>https://jsokit.com/blog/posts/from-handshake-to-heartbeat-building-a-websocket-online-testing-tool/</guid>
      <description>From Handshake to Heartbeat: Building a WebSocket Online Testing Tool Recently, I was developing a real-time chat feature with WebSocket on the backend. Debugging was painful—browser DevTools&amp;rsquo; Network panel shows WebSocket frames, but it&amp;rsquo;s not intuitive. So I built an online testing tool and documented the implementation process.&#xA;WebSocket Connection Lifecycle WebSocket isn&amp;rsquo;t just a simple TCP socket—it has a complete handshake and state management mechanism:&#xA;const ws = new WebSocket(&amp;#39;wss://example.</description>
    </item>
    <item>
      <title>Browser-Based Web Screenshots: From getDisplayMedia API to Canvas Implementation</title>
      <link>https://jsokit.com/blog/posts/browser-based-web-screenshots-from-getdisplaymedia-api-to-canvas-implementation/</link>
      <pubDate>Mon, 11 May 2026 15:05:34 +0000</pubDate>
      <guid>https://jsokit.com/blog/posts/browser-based-web-screenshots-from-getdisplaymedia-api-to-canvas-implementation/</guid>
      <description>Browser-Based Web Screenshots: From getDisplayMedia API to Canvas Implementation I recently built a web screenshot tool, thinking it&amp;rsquo;d be straightforward. Spoiler: I hit several gotchas. Here&amp;rsquo;s what I learned, in case you&amp;rsquo;re tackling the same problem.&#xA;Choosing a Screenshot Approach There are three common approaches for web screenshots:&#xA;Server-side - Use Puppeteer/Playwright to render and capture on the server html2canvas - Frontend library that converts DOM to Canvas getDisplayMedia API - Native browser screen capture API Each has trade-offs:</description>
    </item>
    <item>
      <title>UUID Generator Algorithms: From v1 to v4 Implementation</title>
      <link>https://jsokit.com/blog/posts/uuid-generator-algorithms-from-v1-to-v4-implementation/</link>
      <pubDate>Sun, 10 May 2026 17:07:26 +0000</pubDate>
      <guid>https://jsokit.com/blog/posts/uuid-generator-algorithms-from-v1-to-v4-implementation/</guid>
      <description>UUID Generator Algorithms: From v1 to v4 Implementation Building a distributed system recently, I needed globally unique IDs. Started with auto-increment database IDs, then hit a wall with sharding—different databases would generate conflicting IDs. After some research, I went with UUID. Here&amp;rsquo;s what I learned.&#xA;What is UUID? UUID (Universally Unique Identifier) is a 128-bit unique identifier, typically shown as a 36-character string:&#xA;550e8400-e29b-41d4-a716-446655440000 The format is 8-4-4-4-12, separated by hyphens.</description>
    </item>
    <item>
      <title>URL Encoding Decoded: From Percent Signs to encodeURIComponent</title>
      <link>https://jsokit.com/blog/posts/url-encoding-decoded-from-percent-signs-to-encodeuricomponent/</link>
      <pubDate>Sun, 10 May 2026 11:42:34 +0000</pubDate>
      <guid>https://jsokit.com/blog/posts/url-encoding-decoded-from-percent-signs-to-encodeuricomponent/</guid>
      <description>URL Encoding Decoded: From Percent Signs to encodeURIComponent Last week, I was debugging a payment callback where URL parameters were double-encoded, causing order ID parsing failures. It turned out many developers still treat URL encoding as just &amp;ldquo;throw encodeURIComponent at it.&amp;rdquo; Let me break down the actual mechanics and implementation details.&#xA;The Essence: Percent-Encoding URL encoding is officially called &amp;ldquo;percent-encoding.&amp;rdquo; The rule is straightforward: non-ASCII and special characters are represented as %XX, where XX is the character&amp;rsquo;s hexadecimal ASCII value.</description>
    </item>
    <item>
      <title>Unit Converter: From Floating-Point Precision to Temperature Offsets</title>
      <link>https://jsokit.com/blog/posts/unit-converter-from-floating-point-precision-to-temperature-offsets/</link>
      <pubDate>Sat, 09 May 2026 17:52:56 +0000</pubDate>
      <guid>https://jsokit.com/blog/posts/unit-converter-from-floating-point-precision-to-temperature-offsets/</guid>
      <description>Unit Converter: From Floating-Point Precision to Temperature Offsets I recently needed to convert between inches and centimeters for a project. Wrote a quick formula, but the result didn&amp;rsquo;t match the design specs—that&amp;rsquo;s when I realized unit conversion isn&amp;rsquo;t as simple as it looks.&#xA;Basic Conversion: The Base Unit Method The obvious approach is direct formulas:&#xA;// Inch to centimeter const inchToCm = (inch) =&amp;gt; inch * 2.54 // Centimeter to inch const cmToInch = (cm) =&amp;gt; cm / 2.</description>
    </item>
    <item>
      <title>How LLM Token Counting Works: Building a Client-Side Token Estimator</title>
      <link>https://jsokit.com/blog/posts/how-llm-token-counting-works-building-a-client-side-token-estimator/</link>
      <pubDate>Sat, 09 May 2026 14:41:07 +0000</pubDate>
      <guid>https://jsokit.com/blog/posts/how-llm-token-counting-works-building-a-client-side-token-estimator/</guid>
      <description>How LLM Token Counting Works: Building a Client-Side Token Estimator Every time you call a GPT or Claude API, you&amp;rsquo;re paying by the token. But what exactly is a token, and how do you estimate token counts without loading a 500MB tokenizer model into your browser?&#xA;Let&amp;rsquo;s break down the algorithm behind the Token Counter tool, and why a simple heuristic can get you surprisingly close to the real count.</description>
    </item>
    <item>
      <title>JavaScript Timezone Conversion: From Unix Timestamps to IANA Identifiers</title>
      <link>https://jsokit.com/blog/posts/javascript-timezone-conversion-from-unix-timestamps-to-iana-identifiers/</link>
      <pubDate>Fri, 08 May 2026 17:18:37 +0000</pubDate>
      <guid>https://jsokit.com/blog/posts/javascript-timezone-conversion-from-unix-timestamps-to-iana-identifiers/</guid>
      <description>JavaScript Timezone Conversion: From Unix Timestamps to IANA Identifiers Recently built a cross-timezone meeting scheduler and stepped into quite a few timezone pitfalls. Let me share what I learned about JavaScript timezone handling.&#xA;The Essence: Unix Timestamps Have No Timezone Here&amp;rsquo;s a core concept: timestamps are timezone-agnostic.&#xA;const now = Date.now() // 1714838400000 - milliseconds since UTC 1970-01-01 // Beijing: 2024-05-04 20:00:00 // New York: 2024-05-04 08:00:00 // Same timestamp, different displays No matter where you are on Earth, Date.</description>
    </item>
    <item>
      <title>Unix Timestamp Pitfalls: A Complete Guide to Timestamp Conversion</title>
      <link>https://jsokit.com/blog/posts/unix-timestamp-pitfalls-a-complete-guide-to-timestamp-conversion/</link>
      <pubDate>Fri, 08 May 2026 10:48:36 +0000</pubDate>
      <guid>https://jsokit.com/blog/posts/unix-timestamp-pitfalls-a-complete-guide-to-timestamp-conversion/</guid>
      <description>Unix Timestamp Pitfalls: A Complete Guide to Timestamp Conversion Last week, I was debugging a production issue. The logs were filled with numbers like 1745678901. Our new intern looked confused: &amp;ldquo;What are these?&amp;rdquo; I said, &amp;ldquo;Unix timestamps.&amp;rdquo; He asked, &amp;ldquo;How do I convert them to human-readable time?&amp;rdquo;&#xA;That question made me realize timestamp conversion is trickier than I thought.&#xA;What is a Unix Timestamp? A Unix timestamp is the number of seconds since January 1, 1970, 00:00:00 UTC.</description>
    </item>
  </channel>
</rss>
