Skip to content

Instantly share code, notes, and snippets.

@Stormwind
Stormwind / ReadFilesViaResTest.class.php
Created January 5, 2012 12:54
XP Framework: Bug when using the ResouceProvider class with large files
<?php
uses('lang.ResourceProvider', 'unittest.TestCase');
class ReadFilesViaResTest extends TestCase {
/**
* Running test, when using an normal path
*
*/
@Stormwind
Stormwind / gsub-test.rb
Last active December 10, 2015 01:38
gsub seems to replace the original encoding of the give sting with the encoding of the gsub content.
foo = 'fo'
foo.force_encoding('UTF-8')
puts foo.encoding.inspect # #<Encoding:UTF-8>
foo2 = foo.gsub(/o/) { |bar| 195.chr }
puts foo2.inspect # "f\xC3"
puts foo2.length.inspect # 2
puts foo2.encoding.inspect # #<Encoding:ASCII-8BIT>