metanorma / metanorma-gb

Metanorma processor for GB: write Chinese Standards using GbDoc
BSD 2-Clause "Simplified" License
2 stars 3 forks source link

Fix windows tests #96

Closed CAMOBAP closed 5 years ago

CAMOBAP commented 5 years ago

During https://github.com/metanorma/metanorma-gb/pull/95 two test failure was observed

Looks like encoding issue:

good: :stageabbr=>"Pre三次标准草案征求意见稿", vs bad: :stageabbr=>"PreΣ╕ë次标准草案征求意见稿"

cc @opoudjis

opoudjis commented 5 years ago

How strange. So it's not the Unicode that's bothering it, it's the mixing of Chinese and Roman script.

opoudjis commented 5 years ago

Rather than pore over the whys and wherefores, I'm HTML encoding this one-off instance of script mixing. Will see if that works.

ronaldtse commented 5 years ago

Here is shown as 三. Is this string actually in UTF-8? I suspect not?

opoudjis commented 5 years ago

The issue is in line 113 of lib/isodoc/gb/metadata.rb.

stage = "#{iter.text.to_i.localize(:zh).spellout}次#{stage}" if iter

This uses the https://github.com/twitter/twitter-cldr-rb library to convert an iteration number (in this case "3") into a Chinese character. This works fine in Unix (三次); in Windows, the string it generates is mangled (Σ╕ë次), and is clearly being treated as three bytes and not UTF-8.

I'm trying out force_encoding("UTF-8") on the output of spellout, and if that doesn't work, I'm passing back it to @CAMOBAP795.

opoudjis commented 5 years ago

No, force_encoding didn't work. @CAMOBAP795, over to you.

CAMOBAP commented 5 years ago

@opoudjis ok

CAMOBAP commented 5 years ago

Continue looking at https://github.com/twitter/twitter-cldr-rb I have some progress https://github.com/twitter/twitter-cldr-rb/blob/master/resources/locales/zh/rbnf.yml#L102 now it's time to understand how this config was opened

CAMOBAP commented 5 years ago

Here is problematic line https://github.com/twitter/twitter-cldr-rb/blob/master/lib/twitter_cldr/resources/loader.rb#L109 I have fixed it locally and it works, I'm going to provide PR

CAMOBAP commented 5 years ago

PR is submitted https://github.com/twitter/twitter-cldr-rb/pull/217

opoudjis commented 5 years ago

Our procedure when this has happened in the past is to fetch a local version of the gem until the PR is accepted. @CAMOBAP795, I will do so with your instance. Please let me know if and when the PR is accepted.

opoudjis commented 5 years ago

And we will leave the ticket open until it is...