What does this mojibake/krakozyabry on The Simpsons say? - character-encoding
On Season 12 Episode 07 "The Great Money Caper" of The Simpsons, I noticed a few years ago "gibberish" signs on the Russian spaceship. Randomly today, I decided to search and see if anyone decoded them but couldn't find any results.
I suspect that it is KOI8-R showing up as either Latin-1 or Windows-1252. The image I could grab is not very clear.
I have two interpretations of the mojibake as shown in this Python 3 code interpreter interaction:
>>> 'Ï‹ÏËÏÁ ¿Ä ÄÏÍ.†.'.encode('windows-1252').decode('koi8_r')
'о▀окоа ©д дом.├.'
>>> 'Ï<ÏËÏÁ ¿Ä ÄÏÍ.×.'.encode('latin1').decode('koi8_r')
'о<окоа ©д дом.в.'
Looking at the code charts on Wikpedia, I cannot figure out what the "<"-like and "+"-like symbols are. I thought about brute-forcing and matching it with some sort of spellcheck dictionary but I would rather get some help first.
Can the original text or meaning still be recovered? Or is it really gibberish?
(I appreciate if someone knows what it says, but I would like to see if its possible to solve this through some code.)
Edit: A naive script:
codec_list = ['ascii', 'big5', 'big5hkscs', 'cp037', 'cp424', 'cp437',
'cp500', 'cp720', 'cp737', 'cp775', 'cp850', 'cp852', 'cp855', 'cp856',
'cp857', 'cp858', 'cp860', 'cp861', 'cp862', 'cp863', 'cp864', 'cp865',
'cp866', 'cp869', 'cp874', 'cp875', 'cp932', 'cp949', 'cp950', 'cp1006',
'cp1026', 'cp1140', 'cp1250', 'cp1251', 'cp1252', 'cp1253', 'cp1254',
'cp1255', 'cp1256', 'cp1257', 'cp1258', 'euc_jp', 'euc_jis_2004',
'euc_jisx0213', 'euc_kr', 'gb2312', 'gbk', 'gb18030', 'hz', 'iso2022_jp',
'iso2022_jp_1', 'iso2022_jp_2', 'iso2022_jp_2004', 'iso2022_jp_3',
'iso2022_jp_ext', 'iso2022_kr', 'latin_1', 'iso8859_2', 'iso8859_3',
'iso8859_4', 'iso8859_5', 'iso8859_6', 'iso8859_7', 'iso8859_8',
'iso8859_9', 'iso8859_10', 'iso8859_13', 'iso8859_14', 'iso8859_15',
'iso8859_16', 'johab', 'koi8_r', 'koi8_u', 'mac_cyrillic', 'mac_greek',
'mac_iceland', 'mac_latin2', 'mac_roman', 'mac_turkish', 'ptcp154',
'shift_jis', 'shift_jis_2004', 'shift_jisx0213', 'utf_32', 'utf_32_be',
'utf_32_le', 'utf_16', 'utf_16_be', 'utf_16_le', 'utf_7', 'utf_8',
'utf_8_sig',]
source_str_list = ['Ï‹ÏËÏÁ ¿Ä ÄÏÍ.†.', 'Ï<ÏËÏÁ ¿Ä ÄÏÍ.×.']
for mangled_codec in codec_list:
for correct_codec in codec_list:
decoded_str_list = []
for s in source_str_list:
try:
decoded_str_list.append(s.encode(mangled_codec
).decode(correct_codec))
except (UnicodeEncodeError, UnicodeDecodeError):
continue
if decoded_str_list:
print(mangled_codec, correct_codec, decoded_str_list)
Ï‹ÏËÏÁ¿ÄÄÏÍ.†.
gbk 15 5 '蠇纤狭磕南'
cp932, sjis 31 11 'マ均ヒマチソトトマヘ.'
cp1250 28 14 'Ď‹ĎËĎÁżÄÄĎÍ.†.'
cp1251 28 14 'П‹ПЛПБїДДПН.†.'
cp1256 28 14 'د‹دثدء؟ؤؤدح.†.'
cp1257 28 14 'Ļ‹ĻĖĻĮæÄÄĻĶ.†.'
geostd8 37 14 'ო‹ოლობ¿ეეონ.†.'
Ï<ÏËÏÁ ¿Ä ÄÏÍ
euckr 31 11 '횕<횕횏횕횁쩔횆횆횕횒'
gbk 31 11 '脧<脧脣脧脕驴脛脛脧脥'
Mojibake for Cyrillic usually involves 'eth':
АБВГҐДЂ -> ÐБВГÒДЂ
Mojibaking Greek gets Î and Ï.
Related
Rollbar and Rails: No route matches [GET] "/blog/wp-login.php"
I recently installed Rollbar on my to-be Production instance and I see that Rollbar has starting reporting this issue about not finding a WordPress login. ActionController::RoutingError: No route matches [GET] "/blog/wp-login.php" I searched through all my code and dont find any references wp-login.php and the stack trace is not helping either. Would you know where this might be coming from? "/home/myproject/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.13/lib/action_dispatch/middleware/debug_exceptions.rb" line 21 in call "/home/myproject/shared/bundle/ruby/2.1.0/gems/rollbar-2.7.1/lib/rollbar/middleware/rails/show_exceptions.rb" line 22 in call_with_rollbar "/home/myproject/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.13/lib/action_dispatch/middleware/show_exceptions.rb" line 30 in call "/home/myproject/shared/bundle/ruby/2.1.0/gems/railties-4.0.13/lib/rails/rack/logger.rb" line 38 in call_app "/home/myproject/shared/bundle/ruby/2.1.0/gems/railties-4.0.13/lib/rails/rack/logger.rb" line 20 in block in call "/home/myproject/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.13/lib/active_support/tagged_logging.rb" line 68 in block in tagged "/home/myproject/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.13/lib/active_support/tagged_logging.rb" line 26 in tagged "/home/myproject/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.13/lib/active_support/tagged_logging.rb" line 68 in tagged "/home/myproject/shared/bundle/ruby/2.1.0/gems/railties-4.0.13/lib/rails/rack/logger.rb" line 20 in call "/home/myproject/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.13/lib/action_dispatch/middleware/request_id.rb" line 21 in call "/home/myproject/shared/bundle/ruby/2.1.0/gems/rack-1.5.5/lib/rack/methodoverride.rb" line 21 in call "/home/myproject/shared/bundle/ruby/2.1.0/gems/rack-1.5.5/lib/rack/runtime.rb" line 17 in call "/home/myproject/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.13/lib/action_dispatch/middleware/static.rb" line 84 in call "/home/myproject/shared/bundle/ruby/2.1.0/gems/rack-1.5.5/lib/rack/send.rb" line 112 in call "/home/myproject/shared/bundle/ruby/2.1.0/gems/railties-4.0.13/lib/rails/engine.rb" line 511 in call "/home/myproject/shared/bundle/ruby/2.1.0/gems/railties-4.0.13/lib/rails/application.rb" line 97 in call "/home/myproject/shared/bundle/ruby/2.1.0/gems/railties-4.0.13/lib/rails/railtie/configurable.rb" line 30 in method_missing "/home/myproject/shared/bundle/ruby/2.1.0/gems/unicorn-5.0.1/lib/unicorn/http_server.rb" line 562 in process_client "/home/myproject/shared/bundle/ruby/2.1.0/gems/unicorn-5.0.1/lib/unicorn/http_server.rb" line 658 in worker_loop "/home/myproject/shared/bundle/ruby/2.1.0/gems/unicorn-5.0.1/lib/unicorn/http_server.rb" line 508 in spawn_missing_workers "/home/myproject/shared/bundle/ruby/2.1.0/gems/unicorn-5.0.1/lib/unicorn/http_server.rb" line 132 in start "/home/myproject/shared/bundle/ruby/2.1.0/gems/unicorn-5.0.1/bin/unicorn" line 126 in <top (required)> "/home/myproject/shared/bundle/ruby/2.1.0/bin/unicorn" line 23 in load "/home/myproject/shared/bundle/ruby/2.1.0/bin/unicorn" line 23 in <main>
This is just the random background noise of the internet - scripts wander around looking for known security holes (in this case, one in WordPress) that their human might want to exploit. If someone ever puts your link into an MS Office document, you'll also see weird OPTIONS requests. It's common to configure error reporting to ignore RoutingErrors, though of course there are pros and cons to that. It lets you ignore this noise, which can trigger false alarms, but if you ever actually render a bad URL, it can go unnoticed.
ActiveRecord "IOError: could not reopen: null"
I just experienced my app having errors on every page load or almost every page load. A restart cleared out all the problems. Here is what I think happened. The first error, was "IOError: could not reopen: null" "org/jruby/RubyIO.java" line 501 in reopen "/app/vendor/bundle/jruby/1.9/gems/activesupport-4.0.4/lib/active_support/core_ext/kernel/reporting.rb" line 52 in silence_stream "/app/vendor/bundle/jruby/1.9/gems/activesupport-4.0.4/lib/active_support/core_ext/kernel/reporting.rb" line 109 in quietly "/app/vendor/bundle/jruby/1.9/gems/activesupport-4.0.4/lib/active_support/core_ext/kernel/reporting.rb" line 50 in silence_stream "/app/vendor/bundle/jruby/1.9/gems/activesupport-4.0.4/lib/active_support/core_ext/kernel/reporting.rb" line 108 in quietly "/app/vendor/bundle/jruby/1.9/gems/activerecord-session_store-0.1.0/lib/action_dispatch/session/active_record_store.rb" line 64 in get_session "/app/vendor/bundle/jruby/1.9/gems/rack-1.5.2/lib/rack/session/abstract/id.rb" line 266 in load_session "/app/vendor/bundle/jruby/1.9/gems/actionpack-4.0.4/lib/action_dispatch/middleware/session/abstract_store.rb" line 43 in load_session "/app/vendor/bundle/jruby/1.9/gems/actionpack-4.0.4/lib/action_dispatch/middleware/session/abstract_store.rb" line 51 in stale_session_check! "/app/vendor/bundle/jruby/1.9/gems/actionpack-4.0.4/lib/action_dispatch/middleware/session/abstract_store.rb" line 43 in load_session "/app/vendor/bundle/jruby/1.9/gems/actionpack-4.0.4/lib/action_dispatch/request/session.rb" line 168 in load! "/app/vendor/bundle/jruby/1.9/gems/actionpack-4.0.4/lib/action_dispatch/request/session.rb" line 160 in load_for_read! "/app/vendor/bundle/jruby/1.9/gems/actionpack-4.0.4/lib/action_dispatch/request/session.rb" line 86 in [] "/app/vendor/bundle/jruby/1.9/gems/warden-1.2.3/lib/warden/session_serializer.rb" line 30 in fetch "/app/vendor/bundle/jruby/1.9/gems/warden-1.2.3/lib/warden/proxy.rb" line 212 in user ... There was only one of those. Then, on every page request, i get "Errno::EBADF: Bad file descriptor" "org/jruby/RubyIO.java" line 2097 in close "/app/vendor/bundle/jruby/1.9/gems/activesupport-4.0.4/lib/active_support/core_ext/kernel/reporting.rb" line 53 in silence_stream "/app/vendor/bundle/jruby/1.9/gems/activesupport-4.0.4/lib/active_support/core_ext/kernel/reporting.rb" line 109 in quietly "/app/vendor/bundle/jruby/1.9/gems/activesupport-4.0.4/lib/active_support/core_ext/kernel/reporting.rb" line 50 in silence_stream "/app/vendor/bundle/jruby/1.9/gems/activesupport-4.0.4/lib/active_support/core_ext/kernel/reporting.rb" line 108 in quietly "/app/vendor/bundle/jruby/1.9/gems/activerecord-session_store-0.1.0/lib/action_dispatch/session/active_record_store.rb" line 64 in get_session "/app/vendor/bundle/jruby/1.9/gems/rack-1.5.2/lib/rack/session/abstract/id.rb" line 266 in load_session "/app/vendor/bundle/jruby/1.9/gems/actionpack-4.0.4/lib/action_dispatch/middleware/session/abstract_store.rb" line 43 in load_session ... What cause the initial problem?
weird stuff such as these are likely caused by Rails not being "absolutely" thread-safe (even on MRI but it's more obvious on JRuby since it's "GIL-free") ... Rails.logger.silence and related have not been 100% thread-safe https://gist.github.com/kares/9374772 I've dealt with similar issues (on JRuby on Rails) since 2.3 and there sure were attempts to fix this but somehow the same silencing logic keeps getting back. the whole silence_stream(STDOUT) {} code (that your trace reveals), I would guess, might end up in a similar "unpredictable" state. I would try patching kernel/reporting.rb so that the stream silencers do nothing (I've updated the gist as well).
Ruby Debug: Skip Rails Code
When stepping through the Ruby Debugger in Rails, how do I only have it stop only at code that I wrote, skipping over all the native Rails code? (ie skipping all the code that looks like this) /Users/jon/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.1/lib/active_support/core_ext/module/remove_method.rb:4 remove_method(method) (rdb:1) s [76, 85] in /Users/jon/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.1/lib/active_support/core_ext/class/attribute.rb 76 def self.#{name}?() !!#{name} end 77 78 def self.#{name}=(val) 79 singleton_class.class_eval do 80 remove_possible_method(:#{name}) => 81 define_method(:#{name}) { val } 82 end 83 84 if singleton_class? 85 class_eval do /Users/jon/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.1/lib/active_support/core_ext/class/attribute.rb:81 define_method(:#{name}) { val } (rdb:1) s [79, 88] in /Users/jon/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.1/lib/active_support/core_ext/class/attribute.rb 79 singleton_class.class_eval do 80 remove_possible_method(:#{name}) 81 define_method(:#{name}) { val } 82 end 83 => 84 if singleton_class? 85 class_eval do 86 remove_possible_method(:#{name}) 87 def #{name} 88 defined?(##{name}) ? ##{name} : singleton_class.#{name} Thanks!
I think what your looking for is something like this if I understand your question right. You'll want to step over rather than step into, that way if your using a method for rails you don't go into the rails code. I hope this helps and good luck.
If you occasionally stepped in some Rails code, just press c in a console. This will move you to the next breakpoint you have set (or return to the same one if you're inside a loop) or will simply end page request if there's no breakpoints left.
There are 3 major debugging commands c - Continue s - Step into n - next/ Step over What you're looking for is "n", it allows you to go through a list of methods without going into the code or ruby gem that contains the rest of the code.
Google Analytics tracking code on Rails app error pages
I put my Google Analytics tracking code in my layout file, this of course does not embed it in my error pages (404.html, 500.html) How can I properly track error pages without repeating the code? Are rack-based Google Analytics plugins the way to go? Or is there another preferred way?
I had used this gem in the past https://github.com/leehambley/rack-google-analytics
Hmm. I've got the script in my footer and it seems to track 404 pages. Under content->content dill down: 1. /content/ 17,819 16,542 00:04:56 92.67% 88.91% 2. / 2,640 1,629 00:04:42 66.39% 57.20% 3. /404.html?page=/content/jett-east&from= 110 105 00:01:26 93.33% 93.64% 4. /user 68 41 00:00:59 0.00% 5.88% 5. /user/ 66 26 00:01:52 0.00% 9.09% 6. /404.html?page=/content/tidewater&from= 9 7 00:04:11 33.33% 44.44%
Why am I getting an encoding error with vpim in rails 2?
I get the following error: Vpim::InvalidEncodingError (email#email.net): 2011-06-07T01:37:06+00:00 app[web.1]: .bundle/gems/ruby/1.8/gems/vpim-0.695/lib/vpim/field.rb:110:in `decode0' It has worked fine for other vcards. And the data looks right -- it should be an email: Here is a sample vcard that blows up when there's an email...what I"ve done to fix it is manually remove the second email, but that's a pain: BEGIN:VCARD VERSION:2.1 N:Roberts;Paul;;; FN:Paul Roberts ORG:Sonoma Technology Inc TITLE:EVP Business Dev/Chief Scientific Officer TEL;WORK;VOICE:707-665-9900 TEL;WORK;FAX:707-665-9800 ADR;WORK;ENCODING=QUOTED-PRINTABLE:;;1455 N McDowell Blvd Suite D;Petaluma;CA;94954;USA LABEL;WORK;ENCODING=QUOTED-PRINTABLE:1455 N McDowell Blvd Suite D=0D=0APetaluma, CA 94954=0D=0AUSA URL:http://www.sonomatech.com URL:http://www.sonomatech.com EMAIL;PREF;INTERNET:paul#sonomatech.com paul#sonomatech.com NOTE;ENCODING=QUOTED-PRINTABLE:=0D=0A Data provided by Lead411, http://www.lead411.com/=0D=0A =0D=0A END:VCARD Here's my controller using paperclip and vpim: 68 unless #contact.vcard.path.blank? 69 70 paperclip_vcard = File.new(#contact.vcard.path) 71 72 # try to scrub the vcard 73 scrub_vcf(paperclip_vcard) 74 75 #vcard = Vpim::Vcard.decode(paperclip_vcard).first 76 #contact.title = #vcard.title 77 #contact.email = #vcard.email 78 #contact.first_name = #vcard.name.given 79 #contact.last_name = #vcard.name.family 80 #contact.phone = #vcard.telephones[0] 81 #contact.fax = #vcard.telephones[1] 82 83 #contact.address.street1 = #vcard.address.street 84 #contact.address.city = #vcard.address.locality 85 #contact.address.state = #vcard.address.region 86 #contact.address.zip = #vcard.address.postalcode 87 #contact.company_name = #vcard.org.fetch(0) 88 89 end
You need to look at how your Vcards are being created; the second email on line 14 isn't a valid property definition, which is what's causing the parser to screw up (and which is why it parses successfully if you manually delete it). You can read about the property definition in Section 2 in the Vcard 2.1 specification (the RTF version–which is far more readable–is available here). From the information you provided, this doesn't look like a problem with Vpim on the decoding side, but rather how your Vcards are created. If you're creating the Vcards yourself, I'd take a look at your encoding logic. If you're receiving them from outside sources, then you might want to write some custom scrubbing logic to get rid of improper property definitions, so you don't have to manually remove them yourself. You should be able to do this quite easily with a quick regex check on each line: def scrub_vcf(vcard) line_arr = File.readlines(vcard) line_arr.delete_if { |line| line.match(/^.+\:.+$/).nil? } File.open(vcard, "w") do |f| line_arr.each{|line| f.puts(line)} end end # use the scrubbed vcf with vpim Of course, it would probably be quicker to keep this in an array rather than writing it back out to a file, FYI. Hope that helps. UPDATE: If you don't want to keep the file, you can return a string, which Vpim can decode instead of a file: def scrub_vcf(vcard) line_arr = File.readlines(vcard) line_arr.delete_if { |line| line.match(/^.+\:.+$/).nil? } return line_arr.join end # use the scrubbed vcf with vpim #=> Vpim::Vcard.decode(scrub_vcf(vcard)) Note that I ran into problems with using a String with Vpim::Vcard.decode when running ruby 1.9.x, due to the fact that the String class no longer has an each method. Ruby 1.8.7 works fine, though. Vpim looks like it hasn't been upgraded since 2008/2009, so it's probably not been upgraded for use with ruby 1.9.x. UPDATE AGAIN: Here's a version of Vpim updated for use with ruby 1.9.x (fixes precisely the issue I ran into earlier): https://github.com/sam-github/vpim