GithubHelp home page GithubHelp logo

encoding infos? about highline HOT 5 CLOSED

jeg2 avatar jeg2 commented on June 17, 2024
encoding infos?

from highline.

Comments (5)

JEG2 avatar JEG2 commented on June 17, 2024

Have you made sure the encodings for those Strings are set properly? This code seems to work for me under 1.9.2:

# encoding:  UTF-8

require "rubygems"
require "highline/import"

$terminal.page_at = 20

content = ""
30.times do |n|
  content << "Line #{n + 1} of content…\n"
end

say(content)

from highline.

ghedamat avatar ghedamat commented on June 17, 2024

yep! but my strings are retrieved from an xml file that contains utf8 chars..

I think you're right. maybe i just have to set the encoding correctly ...

do you have an hint on how to do this?
i'm calling str.encode("UTF-8")

on my strings but highline gives the error I've posted above..

tnx for your help

from highline.

ghedamat avatar ghedamat commented on June 17, 2024

btw everything is fine if i'm not using page wrap

using wrap error is:
highline-1.6.1/lib/highline.rb:733:in block in wrap': invalid byte sequence in US-ASCII (ArgumentError) from /usr/local/rvm/gems/ruby-1.9.1-p378/gems/highline-1.6.1/lib/highline.rb:732:ineach_line'

from highline.

JEG2 avatar JEG2 commented on June 17, 2024

Well, if the data is UTF-8 and it's just flagged wrong when it was read in from the XML document, you probably want:

str.force_encoding("UTF-8")

You can read more details about why this is needed on my blog:

http://blog.grayproductions.net/articles/understanding_m17n

from highline.

ghedamat avatar ghedamat commented on June 17, 2024

thank you! I'll have a look as soon as possible and I'll let you know if I'll manage to make it work :)

thanks again

from highline.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.