writeexcel 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitattributes +1 -1
- data/.gitignore +24 -24
- data/README.rdoc +34 -55
- data/VERSION +1 -1
- data/charts/chartex.rb +316 -316
- data/charts/demo1.rb +46 -46
- data/charts/demo2.rb +65 -65
- data/charts/demo3.rb +117 -117
- data/charts/demo4.rb +119 -119
- data/charts/demo5.rb +48 -48
- data/examples/a_simple.rb +43 -43
- data/examples/autofilter.rb +265 -265
- data/examples/bigfile.rb +30 -30
- data/examples/chart_area.rb +121 -121
- data/examples/chart_bar.rb +120 -120
- data/examples/chart_column.rb +120 -120
- data/examples/chart_line.rb +120 -120
- data/examples/chart_pie.rb +108 -108
- data/examples/chart_scatter.rb +121 -121
- data/examples/chart_stock.rb +148 -148
- data/examples/chess.rb +142 -142
- data/examples/colors.rb +129 -129
- data/examples/comments1.rb +27 -27
- data/examples/comments2.rb +352 -352
- data/examples/copyformat.rb +52 -52
- data/examples/data_validate.rb +279 -279
- data/examples/date_time.rb +87 -87
- data/examples/defined_name.rb +32 -32
- data/examples/demo.rb +124 -124
- data/examples/diag_border.rb +36 -36
- data/examples/formats.rb +490 -490
- data/examples/formula_result.rb +30 -30
- data/examples/header.rb +137 -137
- data/examples/hide_sheet.rb +29 -29
- data/examples/hyperlink.rb +43 -43
- data/examples/images.rb +63 -63
- data/examples/indent.rb +31 -31
- data/examples/merge1.rb +40 -40
- data/examples/merge2.rb +45 -45
- data/examples/merge3.rb +66 -66
- data/examples/merge4.rb +83 -83
- data/examples/merge5.rb +80 -80
- data/examples/merge6.rb +67 -67
- data/examples/outline.rb +255 -255
- data/examples/outline_collapsed.rb +209 -209
- data/examples/panes.rb +113 -113
- data/examples/properties.rb +34 -34
- data/examples/properties_jp.rb +33 -33
- data/examples/protection.rb +47 -47
- data/examples/regions.rb +53 -53
- data/examples/repeat.rb +43 -43
- data/examples/right_to_left.rb +27 -27
- data/examples/row_wrap.rb +53 -53
- data/examples/stats.rb +74 -74
- data/examples/stocks.rb +81 -81
- data/examples/tab_colors.rb +31 -31
- data/examples/utf8.rb +15 -15
- data/examples/write_arrays.rb +83 -83
- data/lib/writeexcel/biffwriter.rb +232 -232
- data/lib/writeexcel/caller_info.rb +12 -12
- data/lib/writeexcel/chart.rb +2190 -2177
- data/lib/writeexcel/charts/area.rb +154 -154
- data/lib/writeexcel/charts/bar.rb +177 -177
- data/lib/writeexcel/charts/column.rb +156 -156
- data/lib/writeexcel/charts/external.rb +66 -66
- data/lib/writeexcel/charts/line.rb +154 -154
- data/lib/writeexcel/charts/pie.rb +169 -169
- data/lib/writeexcel/charts/scatter.rb +192 -192
- data/lib/writeexcel/charts/stock.rb +213 -213
- data/lib/writeexcel/colors.rb +64 -64
- data/lib/writeexcel/compatibility.rb +0 -255
- data/lib/writeexcel/debug_info.rb +37 -33
- data/lib/writeexcel/excelformulaparser.rb +587 -587
- data/lib/writeexcel/format.rb +13 -4
- data/lib/writeexcel/formula.rb +26 -9
- data/lib/writeexcel/helper.rb +68 -64
- data/lib/writeexcel/olewriter.rb +311 -311
- data/lib/writeexcel/properties.rb +242 -240
- data/lib/writeexcel/storage_lite.rb +984 -978
- data/lib/writeexcel/workbook.rb +3210 -3192
- data/lib/writeexcel/worksheet.rb +143 -51
- data/lib/writeexcel/write_file.rb +44 -40
- data/lib/writeexcel.rb +1159 -1159
- data/test/helper.rb +31 -28
- data/test/perl_output/README +31 -31
- data/test/test_00_IEEE_double.rb +13 -13
- data/test/test_01_add_worksheet.rb +10 -10
- data/test/test_02_merge_formats.rb +53 -53
- data/test/test_04_dimensions.rb +392 -392
- data/test/test_05_rows.rb +179 -179
- data/test/test_06_extsst.rb +77 -77
- data/test/test_11_date_time.rb +479 -479
- data/test/test_12_date_only.rb +501 -501
- data/test/test_13_date_seconds.rb +481 -481
- data/test/test_21_escher.rb +637 -637
- data/test/test_22_mso_drawing_group.rb +745 -745
- data/test/test_23_note.rb +73 -73
- data/test/test_24_txo.rb +75 -75
- data/test/test_25_position_object.rb +84 -84
- data/test/test_26_autofilter.rb +314 -314
- data/test/test_27_autofilter.rb +131 -131
- data/test/test_28_autofilter.rb +161 -161
- data/test/test_29_process_jpg.rb +683 -683
- data/test/test_30_validation_dval.rb +77 -77
- data/test/test_31_validation_dv_strings.rb +126 -126
- data/test/test_32_validation_dv_formula.rb +206 -206
- data/test/test_40_property_types.rb +188 -188
- data/test/test_41_properties.rb +235 -235
- data/test/test_42_set_properties.rb +437 -437
- data/test/test_50_name_stored.rb +299 -299
- data/test/test_51_name_print_area.rb +357 -357
- data/test/test_52_name_print_titles.rb +454 -454
- data/test/test_53_autofilter.rb +203 -203
- data/test/test_60_chart_generic.rb +578 -578
- data/test/test_61_chart_subclasses.rb +95 -95
- data/test/test_62_chart_formats.rb +272 -272
- data/test/test_63_chart_area_formats.rb +649 -649
- data/test/test_biff.rb +75 -75
- data/test/test_compatibility.rb +12 -627
- data/test/test_example_match.rb +3144 -3144
- data/test/test_formula.rb +61 -61
- data/test/test_ole.rb +106 -106
- data/test/test_storage_lite.rb +125 -125
- data/test/test_workbook.rb +139 -139
- data/test/test_worksheet.rb +110 -110
- data/utils/add_magic_comment.rb +80 -80
- data/writeexcel.gemspec +4 -6
- data/writeexcel.rdoc +58 -15
- metadata +9 -6
- data/test/test_new_encoding.rb +0 -205
data/writeexcel.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{writeexcel}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.6.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Hideo NAKAMURA"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-11-03}
|
13
13
|
s.description = %q{Multiple worksheets can be added to a workbook and formatting can be applied to cells. Text, numbers, formulas, hyperlinks and images can be written to the cells.}
|
14
14
|
s.email = %q{cxn03651@msj.biglobe.ne.jp}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -219,7 +219,6 @@ Gem::Specification.new do |s|
|
|
219
219
|
"test/test_example_match.rb",
|
220
220
|
"test/test_format.rb",
|
221
221
|
"test/test_formula.rb",
|
222
|
-
"test/test_new_encoding.rb",
|
223
222
|
"test/test_ole.rb",
|
224
223
|
"test/test_storage_lite.rb",
|
225
224
|
"test/test_workbook.rb",
|
@@ -231,7 +230,7 @@ Gem::Specification.new do |s|
|
|
231
230
|
s.homepage = %q{http://wiki.github.com/cxn03651/writeexcel/}
|
232
231
|
s.rdoc_options = ["--charset=UTF-8"]
|
233
232
|
s.require_paths = ["lib"]
|
234
|
-
s.rubygems_version = %q{1.3.
|
233
|
+
s.rubygems_version = %q{1.3.7}
|
235
234
|
s.summary = %q{Write to a cross-platform Excel binary file.}
|
236
235
|
s.test_files = [
|
237
236
|
"test/helper.rb",
|
@@ -272,7 +271,6 @@ Gem::Specification.new do |s|
|
|
272
271
|
"test/test_example_match.rb",
|
273
272
|
"test/test_format.rb",
|
274
273
|
"test/test_formula.rb",
|
275
|
-
"test/test_new_encoding.rb",
|
276
274
|
"test/test_ole.rb",
|
277
275
|
"test/test_storage_lite.rb",
|
278
276
|
"test/test_workbook.rb",
|
@@ -331,7 +329,7 @@ Gem::Specification.new do |s|
|
|
331
329
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
332
330
|
s.specification_version = 3
|
333
331
|
|
334
|
-
if Gem::Version.new(Gem::
|
332
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
335
333
|
else
|
336
334
|
end
|
337
335
|
else
|
data/writeexcel.rdoc
CHANGED
@@ -74,7 +74,7 @@ WriteExcelは、エクセルの機能へのできるだけ多くのインター
|
|
74
74
|
|
75
75
|
require 'writeexcel' # Step 0
|
76
76
|
|
77
|
-
workbook =
|
77
|
+
workbook = WriteExcel.new('ruby.xls') # Step 1
|
78
78
|
worksheet = workbook.add_worksheet # Step 2
|
79
79
|
worksheet.write('A1', 'Hi Excel!') # Step 3
|
80
80
|
workbook.close # Step 4
|
@@ -85,7 +85,7 @@ WriteExcelは、エクセルの機能へのできるだけ多くのインター
|
|
85
85
|
|
86
86
|
= Workbook メソッド
|
87
87
|
|
88
|
-
|
88
|
+
WriteExcel ライブラリは新規のワークブックへのオブジェクト指向のインターフェイスを提供します。新たなワークブックに対して次のメソッドを使用することが出来ます。
|
89
89
|
|
90
90
|
new
|
91
91
|
add_worksheet
|
@@ -105,24 +105,24 @@ Spreadsheet::WriteExcel ライブラリは新規のワークブックへのオ
|
|
105
105
|
|
106
106
|
new コンストラクタは新しいエクセルワークブックを作成します。パラメータとしてファイル名かファイルハンドルを受け取ります。(※ファイル名しか対応していません)
|
107
107
|
|
108
|
-
workbook =
|
108
|
+
workbook = WriteExcel.new('filename.xls')
|
109
109
|
worksheet = workbook.add_worksheet
|
110
110
|
worksheet.write(0, 0, 'Hi Excel!')
|
111
111
|
|
112
112
|
※ また、デフォルトのフォーマットを指定することもできます。例えば、MSP ゴシックで11ポイントなど。
|
113
113
|
|
114
|
-
workbook =
|
114
|
+
workbook = WriteExcel.new('filename.xls', :font => 'MSP ゴシック', :size = 11)
|
115
115
|
|
116
116
|
ファイル名を使った別の使用例です。
|
117
117
|
|
118
|
-
workbook =
|
119
|
-
workbook =
|
120
|
-
workbook =
|
121
|
-
workbook =
|
118
|
+
workbook = WriteExcel.new(filename)
|
119
|
+
workbook = WriteExcel.new('/tmp/filename.xls')
|
120
|
+
workbook = WriteExcel.new("c:\\tmp\\filename.xls")
|
121
|
+
workbook = WriteExcel.new('c:\tmp\filename.xls')
|
122
122
|
|
123
123
|
最後の2つの例は、DOSやWindowsでディレクトリの区切りの「\」をエスケープするか、シングルクォートで囲んでそのまま指定していするかの例です。
|
124
124
|
|
125
|
-
new() コンストラクタは、
|
125
|
+
new() コンストラクタは、WriteExcelオブジェクト(ワークブックオブジェクト)を返し、これにワークシートを加えデータを書き込みます。
|
126
126
|
|
127
127
|
== add_worksheet([sheetname])
|
128
128
|
|
@@ -160,11 +160,54 @@ add_format()メソッドは、セルに書式を設定するのに使用する
|
|
160
160
|
|
161
161
|
== set_properties()
|
162
162
|
|
163
|
-
|
163
|
+
タイトル、作成者など文書のプロパティを設定する。これらプロパティは、エクセルで
|
164
|
+
メニューのファイル(F)-プロパティ(I)で見ることができ、他のアプリケーションから
|
165
|
+
読んだり索引付けをすることもできる。
|
166
|
+
|
167
|
+
プロパティは、次のようにハッシュで渡す。
|
168
|
+
|
169
|
+
workbook.set_properties(
|
170
|
+
:title => 'This is an example spreadsheet',
|
171
|
+
:author => 'cxn03651',
|
172
|
+
:comments => 'Created with Ruby and WriteExcel'
|
173
|
+
)
|
174
|
+
|
175
|
+
設定できるプロパティは、
|
176
|
+
|
177
|
+
* タイトル
|
178
|
+
* サブタイトル
|
179
|
+
* 作成者
|
180
|
+
* 管理者
|
181
|
+
* 会社名
|
182
|
+
* 分類
|
183
|
+
* キーワード
|
184
|
+
* コメント
|
185
|
+
|
186
|
+
ユーザー定義のプロパティはサポートしていません。
|
187
|
+
|
188
|
+
UTF-8文字列も渡すことができます。
|
189
|
+
|
190
|
+
workbook.set_properties(
|
191
|
+
:subject => "住所録"
|
192
|
+
)
|
193
|
+
|
194
|
+
通常、WriteExcelはUTF-16の文字を使うことが出来るのですが、文書プロパティ
|
195
|
+
ではUTF-16文字はサポートされていません。
|
196
|
+
|
197
|
+
ルビーとWriteExcelの使い良さを広めるため、文書のプロパティをセットする時には、
|
198
|
+
次のようにコメントをセットしましょう。
|
199
|
+
|
200
|
+
workbook.set_properties(
|
201
|
+
...,
|
202
|
+
:comments => 'Created with Ruby and WriteExcel',
|
203
|
+
...,
|
204
|
+
)
|
205
|
+
|
206
|
+
examples内のproperties.rbプログラムもご覧下さい。
|
164
207
|
|
165
208
|
== set_tempdir()
|
166
209
|
|
167
|
-
速度と効率のため、ワークブックのデータを最後に組み立てる前に、
|
210
|
+
速度と効率のため、ワークブックのデータを最後に組み立てる前に、WriteExcelはワークシートのデータをテンポラリファイルに置きます。テンポラリファイルを作ることが出来ない場合はメモリ上で作業します。この場合、大きなファイルになると遅くなることがあります。
|
168
211
|
この問題はWindows上でIISと併せて使っているときに主として発生しますが、UNIXシステムでも起こることがあります。
|
169
212
|
この問題は概して、既定の一時ファイルディレクトリがC:\やその他IISが書き込みを提供していないディレクトリに設定されているのが原因で発生します。
|
170
213
|
この問題を避けるために、set_tempdir()メソッドを使って一時ファイルを作成できるディレクトリを指定します。
|
@@ -250,7 +293,7 @@ sheets()メソッドはワークブック内のワークシートの全リスト
|
|
250
293
|
|
251
294
|
エクセルは日付を実数で格納しています。その整数部分は「epoch」からの日数を、小数部分は1日のうちのパーセンテージを格納しています。「epoch」は、Windowsのエクセルでは1900年、マッキントッシュのエクセルでは1904年です。ですが、どちらのプラットフォームでもエクセルは自動的にシステム間の相違をコンバートして扱います。
|
252
295
|
|
253
|
-
|
296
|
+
WriteExcelではデフォルトで1900年を用います。もしも変更したいのであれば、workbookに対してset_1904()メソッドを呼んでください。現在の値を問い合わせるにはget_1904()を呼びます。これは、1900ならば0を、1904ならば1を返します。
|
254
297
|
|
255
298
|
エクセルの日付の取り扱いについては、"DATES AND TIME IN EXCEL"も見てください。
|
256
299
|
|
@@ -258,9 +301,9 @@ Spreadsheet::WriteExcelではデフォルトで1900年を用います。もし
|
|
258
301
|
|
259
302
|
== set_codepage(codepage)
|
260
303
|
|
261
|
-
|
304
|
+
WriteExcelで使われるデフォルトのコードページ、文字セットはANSIです。これはWindowsのエクセルの既定値でもあります。しかしながら、たまにコードページを変更する必要が生じたときは、set_codepage()メソッドを使って変更します。
|
262
305
|
|
263
|
-
コードページの変更は、マッキントッシュ上で
|
306
|
+
コードページの変更は、マッキントッシュ上でWriteExcelを使用していて、ASCII 128以外の文字セットを使いたい場合に必要になることがあります。
|
264
307
|
|
265
308
|
workbook.set_codepage(1) # ANSI, MS Windows
|
266
309
|
workbook.set_codepage(2) # Apple Macintosh
|
@@ -617,7 +660,7 @@ URLの形式は4つ(http://, https://, ftp://, mailto:)をサポートして
|
|
617
660
|
|
618
661
|
worksheet.write_url('A15', 'external:c;\temp\foo.xls#my_name')
|
619
662
|
|
620
|
-
注:現在の
|
663
|
+
注:現在のWriteExcelでは、名前付け範囲の設定は対応していません。
|
621
664
|
|
622
665
|
エクセルでは、シート名に空白や非英数字が含まれる場合、'Sales Data'!A1のようにクォートで囲む必要があります。この場合、シート名に含まれる文字は必要であればエスケープしてください。 'c:\temp' はダブルクォートでは"c:\\temp"とします。
|
623
666
|
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: writeexcel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 7
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
+
- 6
|
8
9
|
- 0
|
9
|
-
version: 0.
|
10
|
+
version: 0.6.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Hideo NAKAMURA
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-11-03 00:00:00 +09:00
|
18
19
|
default_executable:
|
19
20
|
dependencies: []
|
20
21
|
|
@@ -230,7 +231,6 @@ files:
|
|
230
231
|
- test/test_example_match.rb
|
231
232
|
- test/test_format.rb
|
232
233
|
- test/test_formula.rb
|
233
|
-
- test/test_new_encoding.rb
|
234
234
|
- test/test_ole.rb
|
235
235
|
- test/test_storage_lite.rb
|
236
236
|
- test/test_workbook.rb
|
@@ -248,23 +248,27 @@ rdoc_options:
|
|
248
248
|
require_paths:
|
249
249
|
- lib
|
250
250
|
required_ruby_version: !ruby/object:Gem::Requirement
|
251
|
+
none: false
|
251
252
|
requirements:
|
252
253
|
- - ">="
|
253
254
|
- !ruby/object:Gem::Version
|
255
|
+
hash: 3
|
254
256
|
segments:
|
255
257
|
- 0
|
256
258
|
version: "0"
|
257
259
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
260
|
+
none: false
|
258
261
|
requirements:
|
259
262
|
- - ">="
|
260
263
|
- !ruby/object:Gem::Version
|
264
|
+
hash: 3
|
261
265
|
segments:
|
262
266
|
- 0
|
263
267
|
version: "0"
|
264
268
|
requirements: []
|
265
269
|
|
266
270
|
rubyforge_project:
|
267
|
-
rubygems_version: 1.3.
|
271
|
+
rubygems_version: 1.3.7
|
268
272
|
signing_key:
|
269
273
|
specification_version: 3
|
270
274
|
summary: Write to a cross-platform Excel binary file.
|
@@ -307,7 +311,6 @@ test_files:
|
|
307
311
|
- test/test_example_match.rb
|
308
312
|
- test/test_format.rb
|
309
313
|
- test/test_formula.rb
|
310
|
-
- test/test_new_encoding.rb
|
311
314
|
- test/test_ole.rb
|
312
315
|
- test/test_storage_lite.rb
|
313
316
|
- test/test_workbook.rb
|
data/test/test_new_encoding.rb
DELETED
@@ -1,205 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'helper'
|
3
|
-
require 'nkf'
|
4
|
-
|
5
|
-
class TC_new_encoding < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
ruby_18 do
|
8
|
-
@kcode = $KCODE
|
9
|
-
$KCODE = 'u'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
ruby_18 { $KCODE = @kcode }
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_finder
|
18
|
-
if RUBY_VERSION < '1.9'
|
19
|
-
%w{ UTF_8 UTF-8 utf-8 utf }.each do |name|
|
20
|
-
e = Encoding.find(name)
|
21
|
-
assert_equal 'UTF_8', e.name
|
22
|
-
assert_equal 2, e.value
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_comparison
|
28
|
-
if RUBY_VERSION < '1.9'
|
29
|
-
assert_equal Encoding.find('US-ASCII'), Encoding.find('ASCII')
|
30
|
-
assert_equal Encoding.find('ASCII-8BIT'), Encoding.find('BINARY')
|
31
|
-
assert_not_equal Encoding.find('ASCII'), Encoding.find('UTF-8')
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
# TEST WITH ALTERNATE Encoding NAMES
|
37
|
-
def test_ascii_str_ascii_to_ascii
|
38
|
-
str = ascii_str_enc_us_ascii
|
39
|
-
assert_equal(Encoding::ASCII, str.encode('ASCII').encoding)
|
40
|
-
end
|
41
|
-
def test_ascii_str_ascii_to_us_ascii
|
42
|
-
str = ascii_str_enc_us_ascii
|
43
|
-
assert_equal(Encoding::US_ASCII, str.encode('US-ASCII').encoding)
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_ascii_str_ascii_to_binary
|
47
|
-
str = ascii_str_enc_us_ascii
|
48
|
-
assert_equal(Encoding::BINARY, str.encode('BINARY').encoding)
|
49
|
-
end
|
50
|
-
def test_ascii_str_ascii_to_ascii_8bit
|
51
|
-
str = ascii_str_enc_us_ascii
|
52
|
-
assert_equal(Encoding::ASCII_8BIT, str.encode('ASCII-8BIT').encoding)
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_ascii_str_utf8_to_ascii
|
56
|
-
str = ascii_str_enc_utf8
|
57
|
-
assert_equal(Encoding::ASCII, str.encode('US-ASCII').encoding)
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_non_ascii_str_utf8_to_ascii
|
61
|
-
str = non_ascii_str_enc_utf8
|
62
|
-
assert_raise(Encoding::UndefinedConversionError) { str.encode('US-ASCII') }
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_ascii_str_utf8_to_binary
|
66
|
-
str = ascii_str_enc_utf8
|
67
|
-
assert_equal(Encoding::BINARY, str.encode('ASCII-8BIT').encoding)
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_non_ascii_str_utf8_to_binary
|
71
|
-
str = non_ascii_str_enc_utf8
|
72
|
-
assert_raise(Encoding::UndefinedConversionError) { str.encode('ASCII-8BIT') }
|
73
|
-
end
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
def ascii_str_enc_ascii
|
78
|
-
str = ["abc"].pack('a*').encode('ASCII')
|
79
|
-
str.encode('ASCII') if RUBY_VERSION < "1.9"
|
80
|
-
str
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_ascii_str_enc_ascii_is_ascii_encoding
|
84
|
-
assert_equal(Encoding::ASCII, ascii_str_enc_ascii.encoding)
|
85
|
-
end
|
86
|
-
|
87
|
-
def ascii_str_enc_us_ascii
|
88
|
-
str = ["abc"].pack('a*').encode('US-ASCII')
|
89
|
-
str.encode('US-ASCII') if RUBY_VERSION < "1.9"
|
90
|
-
str
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_ascii_str_enc_ascii_is_ascii_encoding
|
94
|
-
assert_equal(Encoding::ASCII, ascii_str_enc_us_ascii.encoding)
|
95
|
-
end
|
96
|
-
|
97
|
-
def ascii_str_enc_binary
|
98
|
-
str = ["abc"].pack('a*').encode('BINARY')
|
99
|
-
str.encode('BINARY') if RUBY_VERSION < "1.9"
|
100
|
-
str
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_ascii_str_enc_binary_is_binary_encoding
|
104
|
-
assert_equal(Encoding::BINARY, ascii_str_enc_binary.encoding)
|
105
|
-
end
|
106
|
-
|
107
|
-
def non_ascii_str_enc_binary
|
108
|
-
str = [0x80].pack('v*')
|
109
|
-
str.force_encoding('BINARY')
|
110
|
-
str
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_non_ascii_str_enc_binary
|
114
|
-
assert_equal(Encoding::BINARY, non_ascii_str_enc_binary.encoding)
|
115
|
-
end
|
116
|
-
|
117
|
-
def ascii_str_enc_utf8
|
118
|
-
"abc"
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_ascii_str_enc_utf8_is_utf8_encoding
|
122
|
-
assert_equal(Encoding::UTF_8, ascii_str_enc_utf8.encoding)
|
123
|
-
end
|
124
|
-
|
125
|
-
def non_ascii_str_enc_utf8
|
126
|
-
'あいう'
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_non_ascii_str_enc_utf8
|
130
|
-
assert_equal(Encoding::UTF_8, non_ascii_str_enc_utf8.encoding)
|
131
|
-
end
|
132
|
-
|
133
|
-
def ascii_str_enc_eucjp
|
134
|
-
str = "abc".encode('EUCJP')
|
135
|
-
str
|
136
|
-
end
|
137
|
-
|
138
|
-
def test_ascii_str_enc_eucjp_is_eucjp_encoding
|
139
|
-
assert_equal(Encoding::EUCJP, ascii_str_enc_eucjp.encoding)
|
140
|
-
end
|
141
|
-
|
142
|
-
def non_ascii_str_enc_eucjp
|
143
|
-
str = 'あいう'.encode('EUCJP')
|
144
|
-
str
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_non_ascii_str_enc_eucjp
|
148
|
-
assert_equal(Encoding::EUCJP, non_ascii_str_enc_eucjp.encoding)
|
149
|
-
end
|
150
|
-
|
151
|
-
def ascii_str_enc_sjis
|
152
|
-
str = "abc".encode('SJIS')
|
153
|
-
str
|
154
|
-
end
|
155
|
-
|
156
|
-
def test_ascii_str_enc_sjis_is_sjis_encoding
|
157
|
-
assert_equal(Encoding::SJIS, ascii_str_enc_sjis.encoding)
|
158
|
-
end
|
159
|
-
|
160
|
-
def non_ascii_str_enc_sjis
|
161
|
-
str = 'あいう'.encode('SJIS')
|
162
|
-
str
|
163
|
-
end
|
164
|
-
|
165
|
-
def test_non_ascii_str_enc_sjis
|
166
|
-
assert_equal(Encoding::SJIS, non_ascii_str_enc_sjis.encoding)
|
167
|
-
end
|
168
|
-
|
169
|
-
def ascii_str_enc_utf16le
|
170
|
-
str = NKF.nkf('-w16L0 -m0 -W', "abc")
|
171
|
-
str.force_encoding('UTF_16LE') if RUBY_VERSION < "1.9"
|
172
|
-
str
|
173
|
-
end
|
174
|
-
|
175
|
-
def test_ascii_str_enc_utf16le_is_utf16le_encoding
|
176
|
-
assert_equal(Encoding::UTF_16LE, ascii_str_enc_utf16le.encoding)
|
177
|
-
end
|
178
|
-
|
179
|
-
def non_ascii_str_enc_utf16le
|
180
|
-
str = NKF.nkf('-w16L0 -m0 -W', 'あいう')
|
181
|
-
str.force_encoding('UTF_16LE') if RUBY_VERSION < "1.9"
|
182
|
-
str
|
183
|
-
end
|
184
|
-
|
185
|
-
def test_non_ascii_str_enc_utf16le
|
186
|
-
assert_equal(Encoding::UTF_16LE, non_ascii_str_enc_utf16le.encoding)
|
187
|
-
end
|
188
|
-
|
189
|
-
def ascii_str_enc_utf16be
|
190
|
-
str = NKF.nkf('-w16B0 -m0 -W', "abc")
|
191
|
-
str.force_encoding('UTF_16BE') if RUBY_VERSION < "1.9"
|
192
|
-
str
|
193
|
-
end
|
194
|
-
|
195
|
-
def test_ascii_str_enc_utf16be_is_utf16be_encoding
|
196
|
-
assert_equal(Encoding::UTF_16BE, ascii_str_enc_utf16be.encoding)
|
197
|
-
end
|
198
|
-
|
199
|
-
def non_ascii_str_enc_utf16be
|
200
|
-
str = NKF.nkf('-w16B0 -m0 -W', 'あいう')
|
201
|
-
str.force_encoding('UTF_16BE') if RUBY_VERSION < "1.9"
|
202
|
-
str
|
203
|
-
end
|
204
|
-
|
205
|
-
end
|