---
title: "ruby tk invalid multibyte char (US-ASCII)"
author: "RobinWu"
date: "2011-07-25T08:45:15Z"
tags: ["Ruby"]
categories: ["编程语言"]
slug: "ruby-tk-invalid-multibyte-char-us-ascii"
draft: false
lastmod: "2011-07-25T08:45:15Z"
id: 1131982
url: "https://robinwu.iteye.com/blog/1131982"
---

> 
> [url]http://d.hatena.ne.jp/kano4/20110607/ruby_invalid_multibyte[/url]
> 



```java

# encoding: utf-8
require 'tk'

msg="你好！中国"
root=TkRoot.new{title msg}
label_msg=TkLabel.new(root){
  text  msg
  pack :padx=>2,:pady=>2,:side=>'top'
  font "arial 20 bold"
}
  
TkButton.new(root){
  text "输出属性值"
  pack :padx=>2,:pady=>2,:side=>'bottom'
  command{
    
    puts label_msg.cget('text')
    puts label_msg.cget('justify')
    puts label_msg.cget('border')
    
  }
}
  
Tk.mainloop

```