Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fall back to ISO-8859-1 if UTF-8 fails #326

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions package/bin/irc/irc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 25 additions & 3 deletions package/bin/irc/irc_util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions test/irc_utils_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
(function() {
"use strict";

describe("IRC Utils provides the following functions:", function() {

var waitsForArrayBufferConversion;
waitsForArrayBufferConversion = function() {
return waitsFor((function() {
return !window.irc.util.isConvertingArrayBuffers();
}), 'wait for array buffer conversion', 500);
};

describe("fromSocketData", function() {
var fromSocketData = irc.util.fromSocketData;
var ab, cb;
beforeEach(function() {
cb = jasmine.createSpy('cb');
});

describe("handles encoding", function() {
[
['UTF-8', [0x61, 0xE2, 0x9C, 0x93], 'a✓'],
['ISO-8859-1', [0x74, 0x73, 0x63, 0x68, 0xFC, 0xDF], 'tschüß']
].forEach(function(parts) {
var encoding = parts[0],
array = parts[1],
text = parts[2];
it(encoding, function() {
ab = irc.util.arrayToArrayBuffer(array);
fromSocketData(ab, cb);
waitsForArrayBufferConversion();
return runs(function() {
expect(cb).toHaveBeenCalledWith(text, encoding);
});
});
});
});
});
});
})();
5 changes: 3 additions & 2 deletions test/test_runner.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Jasmine Spec Runner</title>

<link rel="shortcut icon" type="image/png" href="jasmine-1.2.0/jasmine_favicon.png">
Expand Down Expand Up @@ -91,6 +91,7 @@

<!-- spec files -->
<script src="window_message_renderer_test.js"></script>
<script src="irc_utils_test.js"></script>
<script src="irc_test.js"></script>
<script src="script_command_handler_test.js"></script>
<script src="script_handler_test.js"></script>
Expand Down