Comments (11)
@drchainmail,
"UTF-8 is a variable-width encoding that can represent every character in the Unicode character set. It was designed for backward compatibility with ASCII and to avoid the complications of endianness and byte order marks in UTF-16 and UTF-32." [http://en.wikipedia.org/wiki/UTF-8], so you can (and should, as hinted by the default value of xml encoding, which is, guess, utf-8) use utf-8 to represent Unicode characters.
If your xml parser is failing, it is not receiving an utf-8 encoded stream, do you process the resulting string somehow before parsing it?
from builder.
utf-8 is should be fine for any XML parser, as long as the string is actually encoded as utf-8. Can you provide a simple example where builder is not generating proper utf-8 output (given utf-8 input)?
from builder.
I have a similar issue. In the XML-File all special characters are converted but i need it unchanged for further processing.
$KCODE = 'UTF8'
xml = Builder::Markup.new
xml.instruct!(:xml, :encoding => "UTF-8")
xml.sample("Iñtërnâtiônàl")
xml.target!
But when i try this out i get a XML-File with:
I#241;t#235;rn#226;ti#244;n#224;l (i removed "&" here otherwise the ascii character conversion is not visible here) instead of Iñtërnâtiônàl
from builder.
I can't reproduce this.
# -*- coding: utf-8 -*-
require 'builder'
$KCODE = 'UTF8'
xml = Builder::XmlMarkup.new
xml.instruct!(:xml, :encoding => "UTF-8")
xml.sample("Iñtërnâtiônàl")
puts xml.target!
Gives:
$ ruby -v xxx.rb
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.3.0]
xxx.rb:4: warning: variable $KCODE is no longer effective; ignored
<?xml version="1.0" encoding="UTF-8"?><sample>Iñtërnâtiônàl</sample>
$
What version of Ruby are you using? 2.0 reports that $KCODE is ignored.
from builder.
I use Ruby 1.8.7
from builder.
Even with 1.8.7 I get:
$ ruby -v -rubygems xxx.rb
ruby 1.8.7 (2012-06-29 patchlevel 370) [i686-darwin12.2.0]
<?xml version="1.0" encoding="UTF-8"?><sample>Iñtërnâtiônàl</sample>
$
Any other environmental issues that may effect this (OS, etc)?
from builder.
We use Windows Server and MS IIS as Webserver, Ruby 1.8.7, Rails 3.0.20.
Please take a look at my post at stackoverflow:
http://stackoverflow.com/questions/17067241/ruby-1-8-7-file-encoding-render-to-string-ansi-instead-of-utf-8
I added a few screenshots, maybe the problem is the file-encoding of the generated xml-file.
from builder.
You are using the latest version of builder, right? (3.2.2)
from builder.
ok, actually not, but i updated the builder gem to 3.2.2 and tested it again and no changes. The special chars are still converted into ascii
from builder.
Wait, i got the following output
C:\Appl_Ruby>gem dependency --reverse-dependencies builder
Gem builder-2.1.2
Used by
actionpack-3.0.11 (builder (> 2.1.2))> 2.1.2))
activemodel-3.0.11 (builder (
Gem builder-3.2.2
from builder.
With version 2.1.2 I get the same output as you. It's a version issue. According to the CHANGELOG, you need at least version 2.2.0 to get the behavior you want.
from builder.
Related Issues (20)
- Nested cdata in cdata! should raise exceptions HOT 2
- Add option to make xml.tag! handle nil values like rails ActiveRecord::Base#to_xml HOT 1
- Support customized attribute quote character HOT 1
- Change in Ruby's devault encoding breaks test suite with Ruby 2.0 HOT 1
- Doc parse nit during rails 3.2.13.rc1 install HOT 2
- Add to_s HOT 6
- Doc and license files missing in the distributed .gem HOT 1
- Using text! introduces unwanted whitespace HOT 2
- Improper indentation for raw text HOT 1
- download timeout
- 'rake' doesn't work if 'rvm' is not installed
- Rake failure & how to run unit test
- Ruby 2.4 Constant ::Fixnum is deprecated HOT 1
- New repository for builder updates (?) HOT 9
- ANN: New official repo is https://github.com/tenderlove/builder
- why generating a xml, fills my logs with `- - "new"` message ? HOT 1
- Excluding & passing in xml
- "Instruct!" does not work HOT 1
- git tags out of sync with rubygems HOT 2
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 builder.