Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
2605fe70
Commit
2605fe70
authored
16 years ago
by
Henrik (Grubba) Grubbström
Browse files
Options
Downloads
Patches
Plain Diff
Added support for encoding and decoding of GSM 03.38.
Rev: lib/modules/Locale.pmod/Charset.pmod/module.pmod:1.59
parent
e82da9ef
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/Locale.pmod/Charset.pmod/module.pmod
+62
-0
62 additions, 0 deletions
lib/modules/Locale.pmod/Charset.pmod/module.pmod
with
62 additions
and
0 deletions
lib/modules/Locale.pmod/Charset.pmod/module.pmod
+
62
−
0
View file @
2605fe70
...
@@ -263,6 +263,35 @@ private class ISO6937dec {
...
@@ -263,6 +263,35 @@ private class ISO6937dec {
}
}
}
}
// Decode GSM 03.38.
private class GSM03_38dec {
static Decoder decoder = rfc1345("gsm0338");
static string trailer = "";
string drain()
{
// Escape sequences for GSM 03.38.
// cf http://en.wikipedia.org/wiki/Short_message_service
string res =
replace(trailer + decoder->drain(),
"\eØ\e\u039b\e(\e)\e/\e<\e=\e>\e¡\ee"/2,
"\f^{}\\[~]|\u20ac"/1);
trailer = "";
if (sizeof(res) && res[-1] == '\e') trailer = "\e";
return replace(res, "\e", "");
}
this_program feed(string s)
{
decoder->feed(s);
return this;
}
this_program clear()
{
decoder->clear();
trailer = "";
return this;
}
}
private string normalize(string in) {
private string normalize(string in) {
if(!in) return 0;
if(!in) return 0;
string out = replace(lower_case(in),
string out = replace(lower_case(in),
...
@@ -331,6 +360,8 @@ Decoder decoder(string name)
...
@@ -331,6 +360,8 @@ Decoder decoder(string name)
"isoir156": ISO6937dec,
"isoir156": ISO6937dec,
"iso6937": ISO6937dec,
"iso6937": ISO6937dec,
"iso69372001": ISO6937dec,
"iso69372001": ISO6937dec,
"gsm": GSM03_38dec,
"gsm0338": GSM03_38dec,
])[name];
])[name];
if(p)
if(p)
...
@@ -496,6 +527,35 @@ private class ISO6937enc {
...
@@ -496,6 +527,35 @@ private class ISO6937enc {
}
}
}
}
// Encode GSM 03.38.
private class GSM03_38enc {
static Encoder encoder;
static void create(string|void replacement,
function(string:string)|void repcb)
{
encoder = rfc1345("gsm0338", 1, replacement, repcb);
}
string drain()
{
return encoder->drain();
}
this_program feed(string s)
{
// Escape sequences for GSM 03.38.
// cf http://en.wikipedia.org/wiki/Short_message_service
s = replace(s,
"\f^{}\\[~]|\u20ac"/1,
"\eØ\e\u039b\e(\e)\e/\e<\e=\e>\e¡\ee"/2);
encoder->feed(s);
return this;
}
this_program clear()
{
encoder->clear();
return this;
}
}
//! Returns a charset encoder object.
//! Returns a charset encoder object.
//!
//!
//! @param name
//! @param name
...
@@ -550,6 +610,8 @@ Encoder encoder(string name, string|void replacement,
...
@@ -550,6 +610,8 @@ Encoder encoder(string name, string|void replacement,
"utf7½": UTF7_5enc,
"utf7½": UTF7_5enc,
"gb18030": GB18030Enc,
"gb18030": GB18030Enc,
"gbk": GBKenc,
"gbk": GBKenc,
"gsm": GSM03_38enc,
"gsm0338": GSM03_38enc,
"936": GBKenc,
"936": GBKenc,
"shiftjis": ShiftJisEnc,
"shiftjis": ShiftJisEnc,
"mskanji": ShiftJisEnc,
"mskanji": ShiftJisEnc,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment