About: Translate text between different character sets   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

Unfortunately, the original command fails in this case. Below is an updated version which is probably slower, but more powerful, as well as a map for my favorite way to use it. Also included is a character-switching function I developed in the process, but ended up including inline for efficiency. It turns out that directly assigning to a character in a string (let string[i] = a:new[pos]) is illegal, probably because the rhs can include more than one byte. StrSwitchPos() takes care of that, but doesn't enforce a single-byte replacement.

AttributesValues
rdfs:label
  • Translate text between different character sets
rdfs:comment
  • Unfortunately, the original command fails in this case. Below is an updated version which is probably slower, but more powerful, as well as a map for my favorite way to use it. Also included is a character-switching function I developed in the process, but ended up including inline for efficiency. It turns out that directly assigning to a character in a string (let string[i] = a:new[pos]) is illegal, probably because the rhs can include more than one byte. StrSwitchPos() takes care of that, but doesn't enforce a single-byte replacement.
Version
  • 5(xsd:double)
dbkwik:vim/property/wikiPageUsesTemplate
Previous
  • 785(xsd:integer)
Author
  • Breadman
Complexity
  • intermediate
Created
  • 2004-09-09(xsd:date)
ID
  • 786(xsd:integer)
NEXT
  • 787(xsd:integer)
Rating
  • 0(xsd:integer)
abstract
  • Unfortunately, the original command fails in this case. Below is an updated version which is probably slower, but more powerful, as well as a map for my favorite way to use it. Also included is a character-switching function I developed in the process, but ended up including inline for efficiency. It turns out that directly assigning to a character in a string (let string[i] = a:new[pos]) is illegal, probably because the rhs can include more than one byte. StrSwitchPos() takes care of that, but doesn't enforce a single-byte replacement. " Translate character sets, either in the current line, on a range, or in a string " Note that in this version, unmatched characters in old are deleted command! -nargs=* -range Transform , call Transform() function! Transform(old, new, ...) let string = a:0 ? a:1 : getline('.') let i = strlen(string) while i > 0 let i = i - 1 let pos = stridx(a:old, string[i]) if pos > -1 let string = strpart(string, 0, i) . a:new[pos] . strpart(string, i + 1) endif endwhile if a:0 return string else call setline('.', string) endif endfunction noremap "" :Transform "' '" " Spin-off from the above: switch a single character specified by index fun! StrSwitchPos(string, pos, char) return strpart(a:string, 0, a:pos) . a:char . strpart(a:string, a:pos + 1) endfun
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software