mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Default IO::Buffer#get_string to use BINARY encoding.
				
					
				
			This commit is contained in:
		
							parent
							
								
									c3d8d26ad7
								
							
						
					
					
						commit
						da46b8d8e5
					
				
				
				Notes:
				
					git
				
				2021-12-21 08:26:08 +09:00 
				
			
			
			
		
		
					 2 changed files with 5 additions and 2 deletions
				
			
		|  | @ -1125,7 +1125,7 @@ io_buffer_get_string(int argc, VALUE *argv, VALUE self) | ||||||
| 
 | 
 | ||||||
|     size_t offset = 0; |     size_t offset = 0; | ||||||
|     size_t length = data->size; |     size_t length = data->size; | ||||||
|     rb_encoding *encoding = NULL; |     rb_encoding *encoding = rb_ascii8bit_encoding(); | ||||||
| 
 | 
 | ||||||
|     if (argc >= 1) { |     if (argc >= 1) { | ||||||
|         offset = NUM2SIZET(argv[0]); |         offset = NUM2SIZET(argv[0]); | ||||||
|  |  | ||||||
|  | @ -71,7 +71,10 @@ class TestIOBuffer < Test::Unit::TestCase | ||||||
| 
 | 
 | ||||||
|   def test_file_mapped |   def test_file_mapped | ||||||
|     buffer = File.open(__FILE__) {|file| IO::Buffer.map(file)} |     buffer = File.open(__FILE__) {|file| IO::Buffer.map(file)} | ||||||
|     assert_include buffer.get_string, "Hello World" |     contents = buffer.get_string | ||||||
|  | 
 | ||||||
|  |     assert_include contents, "Hello World" | ||||||
|  |     assert_equal Encoding::BINARY, contents.encoding | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   def test_file_mapped_invalid |   def test_file_mapped_invalid | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Samuel Williams
						Samuel Williams