Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteb1575e

Browse files
committed
Ensure that hex/dec extract only find sequences that end correctly.
Separate hex and dec extraction, per the select control.
1 parentd949111 commiteb1575e

File tree

2 files changed

+19
-24
lines changed

2 files changed

+19
-24
lines changed

‎beta.html

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ <h2 class="flush">Related links</h2>
331331
</div>
332332
</aside>
333333

334-
<pid="status">Updated<!-- #BeginDate format:IS1m -->2018-07-257:38<!-- #EndDate --> &bull; tags<ahref="http://rishida.net/blog/index.php?tag=converter"title="Show all blog posts tagged with 'converter'">converter</a>,<ahref="http://rishida.net/blog/?tag=scriptnotes"title="Show all blog posts tagged with 'scriptnotes'">scriptnotes</a></p>
334+
<pid="status">Updated<!-- #BeginDate format:IS1m -->2018-07-258:10<!-- #EndDate --> &bull; tags<ahref="http://rishida.net/blog/index.php?tag=converter"title="Show all blog posts tagged with 'converter'">converter</a>,<ahref="http://rishida.net/blog/?tag=scriptnotes"title="Show all blog posts tagged with 'scriptnotes'">scriptnotes</a></p>
335335

336336

337337
<section>
@@ -342,17 +342,11 @@ <h2>Standard use</h2>
342342

343343
<p>Note, also, that the escapes \n, \t, \b, and \" etc, are recognised by default. If you check the box next to<code>Convert \n etc</code> they will be ignored. For full CSS behaviour here, use the CSS input field.</p>
344344

345-
<p>The<codeclass="kw"translate="no">Extract</code> button strips away everything but the escapes. For example, it will turn<code>The first row is U+0A73
346-
ura
347-
, U+0A05
348-
a
349-
, U+0A72
350-
iri
351-
, U+0A38
352-
sa
353-
, U+0A39
354-
ha.</code>
355-
into<code>U+0A73 U+0A05 U+0A72 U+0A38 U+0A39</code>. It doesn't recognise escapes such as \n, \t, etc. Nor does it recognise character entities, such as<code>&amp;aacute;</code>. If you have selected<codeclass="kw"translate="no">Hex code points</code> or<codeclass="kw"translate="no">Dec code points</code> in the adjacent select control, it will also leave behind hex or decimal numbers. For example, it will turn<code>&lt;0915, 094E, 0947></code> into<code>0915 094E 0947</code>. Note, however, that it may not always get this right. A word like 'decomposition' will result in 'dec' being treated as a number. It only detects numbers if they are preceded by a space, a predefined set of punctuation marks, or the start of the text. It treats UTF-8 and UTF-16 code units as hex code point numbers.</p>
345+
<p><spanclass="leadin">The<codeclass="kw"translate="no">Extract</code> button</span> strips away everything but the escapes. For example, it will turn "<code>The first row is U+0A73 ura, U+0A05 a, U+0A72 iri, U+0A38 sa, U+0A39 ha.</code>" into "<code>U+0A73 U+0A05 U+0A72 U+0A38 U+0A39</code>".</p>
346+
347+
<p>It currently doesn't recognise escapes such as \n, \t, etc. Nor does it recognise character entities, such as<code>&amp;aacute;</code>.</p>
348+
349+
<p>If you have selected<codeclass="kw"translate="no">Hex code points</code> or<codeclass="kw"translate="no">Dec code points</code> in the adjacent select control, it will also leave behind hex or decimal numbers. For example, it will turn "<code>&lt;0915, 094E, 0947></code>" into "<code>0915 094E 0947</code>" or "<code>0915 0947</code>", respectively. Note, however, that it may not always get this right. Text such as '(dec)' will result in 'dec' being treated as a number. It only detects numbers if they are preceded and followed by a space, a particular set of punctuation marks, or the start/end of the text. It treats UTF-8 and UTF-16 code units as hex code point numbers.</p>
356350

357351
<p><spanclass="leadin">Special use.</span> If you only want to convert a specific type of escape and leave all others untouched, paste the text into one of the other boxes and hit its associated<code>Convert</code> button.</p>
358352

‎conversionfunctions-beta.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ function extractEscapes (strIn) {
9999
strIn+=' '
100100
varstr=''
101101
varhexSet=newSet(['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'])
102-
varseparatorSet=newSet([' ',',','<','(','{','-','+','[','/','|','"','\'',':',';'])
102+
vardecSet=newSet(['0','1','2','3','4','5','6','7','8','9'])
103+
varseparatorSet=newSet([' ',',','<','>','(',')','{','}','-','+','[',']','/','|','"','\'',':',';','\u00AB','\u00BB','\u2018','\u2019','\u201C','\u201D','\u3008','\u3009','\u300A','\u300B','\u300C','\u300D','\u300E','\u300F','\u00B7','\u3001','\u3002'])
103104

104105

105106
varchars=[...strIn]
@@ -181,20 +182,20 @@ function extractEscapes (strIn) {
181182
str+=''
182183
i=p-1
183184
}
184-
elseif((document.getElementById('numbers').value==='hex'||document.getElementById('numbers').value==='dec')&&hexSet.has(chars[i].toLowerCase())&&i<chars.length-3&&separatorSet.has(chars[i-1].toLowerCase())&&hexSet.has(chars[i+1].toLowerCase())){
185+
elseif(document.getElementById('numbers').value==='hex'&&hexSet.has(chars[i].toLowerCase())&&i<chars.length-3&&separatorSet.has(chars[i-1].toLowerCase())&&hexSet.has(chars[i+1].toLowerCase())){
185186
letp=i+1
186-
str+=' '+chars[i]
187-
while(p<chars.length-3&&p<i+6&&hexSet.has(chars[p].toLowerCase()))str+=chars[p++]
188-
str+=''
187+
lettemp=' '+chars[i]
188+
while(p<chars.length-3&&p<i+6&&hexSet.has(chars[p].toLowerCase()))temp+=chars[p++]
189+
if(separatorSet.has(chars[p].toLowerCase()))str+=temp
190+
i=p-1
191+
}
192+
elseif(document.getElementById('numbers').value==='dec'&&decSet.has(chars[i].toLowerCase())&&i<chars.length-3&&separatorSet.has(chars[i-1].toLowerCase())&&decSet.has(chars[i+1].toLowerCase())){
193+
letp=i+1
194+
lettemp=' '+chars[i]
195+
while(p<chars.length-3&&p<i+6&&decSet.has(chars[p].toLowerCase()))temp+=chars[p++]
196+
if(separatorSet.has(chars[p].toLowerCase()))str+=temp
189197
i=p-1
190198
}
191-
// else if (i<chars.length-3 && chars[i]===' ' && hexSet.has(chars[i+1].toLowerCase()) && hexSet.has(chars[i+2].toLowerCase()) && (document.getElementById('numbers').value==='hex' || document.getElementById('numbers').value==='dec')) {
192-
// let p = i+1
193-
// str += ' '
194-
// while (p < chars.length-3 && p<i+8 && hexSet.has(chars[p].toLowerCase())) str += chars[p++]
195-
// str += ''
196-
// i = p-1
197-
// }
198199
else{str+=' '}// do nothing
199200
}
200201

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp