Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
78ab979e
Commit
78ab979e
authored
Jan 07, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mruby-string-utf8: redefine String#size for UTF-8 string; #1646
parent
dc25f85b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
+9
-0
mrbgems/mruby-string-utf8/src/string.c
mrbgems/mruby-string-utf8/src/string.c
+9
-0
No files found.
mrbgems/mruby-string-utf8/src/string.c
View file @
78ab979e
...
@@ -47,6 +47,14 @@ mrb_utf8_strlen(mrb_value str)
...
@@ -47,6 +47,14 @@ mrb_utf8_strlen(mrb_value str)
return
total
;
return
total
;
}
}
static
mrb_value
mrb_str_size
(
mrb_state
*
mrb
,
mrb_value
str
)
{
size_t
size
=
mrb_utf8_strlen
(
str
);
return
mrb_fixnum_value
(
size
);
}
#define RSTRING_LEN_UTF8(s) mrb_utf8_strlen(s)
#define RSTRING_LEN_UTF8(s) mrb_utf8_strlen(s)
static
mrb_value
static
mrb_value
...
@@ -244,6 +252,7 @@ mrb_mruby_string_utf8_gem_init(mrb_state* mrb)
...
@@ -244,6 +252,7 @@ mrb_mruby_string_utf8_gem_init(mrb_state* mrb)
{
{
struct
RClass
*
s
=
mrb
->
string_class
;
struct
RClass
*
s
=
mrb
->
string_class
;
mrb_define_method
(
mrb
,
s
,
"size"
,
mrb_str_size
,
MRB_ARGS_NONE
());
mrb_define_method
(
mrb
,
s
,
"[]"
,
mrb_str_aref_m
,
MRB_ARGS_ANY
());
mrb_define_method
(
mrb
,
s
,
"[]"
,
mrb_str_aref_m
,
MRB_ARGS_ANY
());
mrb_define_method
(
mrb
,
s
,
"slice"
,
mrb_str_aref_m
,
MRB_ARGS_ANY
());
mrb_define_method
(
mrb
,
s
,
"slice"
,
mrb_str_aref_m
,
MRB_ARGS_ANY
());
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment