<commit_before># Takes care of recoding pages to Shift-JIS for some handsets when required
require 'nkf'
class Galakei::Filter::Recode < Galakei::Filter::Base
  def self.inject(klass)
    this_class = self
    klass.around_filter self, :if => lambda {|c| this_class.condition?(c) }
  end

  def condition?
    request.ssl? && request.au_browser_6?
  end

  def filter
    deep_apply(controller.params) do |param|
      NKF.nkf('-Sw', param)
    end
    yield
    doc = Nokogiri::HTML(response.body)
    response.body = doc.serialize(:encoding => 'Shift_JIS')
    response.charset = "Shift_JIS"
  end

  private
  def deep_apply(obj, &proc)<commit_msg>use shift-jis for all au handsets when using SSL, easier (new au ahndsets still send response in shift-jis...)<commit_after># Takes care of recoding pages to Shift-JIS for some handsets when required
require 'nkf'
class Galakei::Filter::Recode < Galakei::Filter::Base
  def self.inject(klass)
    this_class = self
    klass.around_filter self, :if => lambda {|c| this_class.condition?(c) }
  end

  def condition?
    request.ssl? && request.au?
  end

  def filter
    deep_apply(controller.params) do |param|
      NKF.nkf('-Sw', param)
    end
    yield
    doc = Nokogiri::HTML(response.body)
    response.body = doc.serialize(:encoding => 'Shift_JIS')
    response.charset = "Shift_JIS"
  end

  private
  def deep_apply(obj, &proc)
{'fraction_non_alphanumeric': 0.11519078473722102, 'fraction_numerical': 0.0007199424046076314, 'mean_word_length': 3.68013468013468, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6316889', 'n_tokens_mistral': 480, 'n_tokens_neox': 468, 'n_words': 126}