Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F10384361
strings.go
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
415 B
Subscribers
None
strings.go
View Options
package
stringmanip
// Substring provides a safe way to extract a substring from a UTF-8 string.
// From this discussion:
// https://groups.google.com/d/msg/golang-nuts/cGq1Irv_5Vs/0SKoj49BsWQJ
func
Substring
(
s
string
,
p
,
l
int
)
string
{
if
p
<
0
||
l
<=
0
{
return
""
}
c
:=
[]
rune
(
s
)
if
p
>
len
(
c
)
{
return
""
}
else
if
p
+
l
>
len
(
c
)
||
p
+
l
<
p
{
return
string
(
c
[
p
:])
}
return
string
(
c
[
p
:
p
+
l
])
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 2:54 PM (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3104022
Attached To
rWC Write.as Web Core
Event Timeline
Log In to Comment