{"id":6840,"date":"2021-12-23T03:00:34","date_gmt":"2021-12-23T03:00:34","guid":{"rendered":"https:\/\/www.qec.tw\/?p=6840"},"modified":"2021-12-28T09:26:10","modified_gmt":"2021-12-28T09:26:10","slug":"stringobject","status":"publish","type":"post","link":"https:\/\/www.qec.tw\/zh\/86duino-reference\/stringobject\/","title":{"rendered":"String"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">[Data Types]<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"_description\">Description<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The String class allows you to use and manipulate strings of text in more complex ways than&nbsp;<a href=\"http:\/\/www.86duino.com\/?p=1497\" target=\"_blank\" rel=\"noopener\">character arrays<\/a>&nbsp;do. You can concatenate Strings, append to them, search for and replace substrings, and more. It takes more memory than a simple character array, but it is also more useful.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For reference, character arrays are referred to as strings with a small s, and instances of the String class are referred to as Strings with a capital S. Note that constant strings, specified in \u201cdouble quotes\u201d are treated as char arrays, not instances of the String class.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Functions<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>[Language] <a href=\"https:\/\/www.qec.tw\/86duino-reference\/stringcast\/\">String<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3035\" target=\"_blank\" rel=\"noopener\">charAt<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3037\" target=\"_blank\" rel=\"noopener\">compareTo<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3039\" target=\"_blank\" rel=\"noopener\">concat<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3041\" target=\"_blank\" rel=\"noopener\">endsWith<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3043\" target=\"_blank\" rel=\"noopener\">equals<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3045\" target=\"_blank\" rel=\"noopener\">equalsIgnoreCase<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3047\" target=\"_blank\" rel=\"noopener\">getBytes<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3049\" target=\"_blank\" rel=\"noopener\">indexOf<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3051\" target=\"_blank\" rel=\"noopener\">lastIndexOf<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3053\" target=\"_blank\" rel=\"noopener\">length<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3055\" target=\"_blank\" rel=\"noopener\">replace<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3057\" target=\"_blank\" rel=\"noopener\">reserve<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3059\" target=\"_blank\" rel=\"noopener\">setCharAt<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3061\" target=\"_blank\" rel=\"noopener\">startsWith<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3064\" target=\"_blank\" rel=\"noopener\">substring<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3066\" target=\"_blank\" rel=\"noopener\">toCharArray<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3068\" target=\"_blank\" rel=\"noopener\">toInt<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3070\" target=\"_blank\" rel=\"noopener\">toLowerCase<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3072\" target=\"_blank\" rel=\"noopener\">toUpperCase<\/a>()<\/li><li>[Language]\u00a0<a href=\"http:\/\/www.86duino.com\/?p=3074\" target=\"_blank\" rel=\"noopener\">trim<\/a>()<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Operators<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>[Language]&nbsp;<a href=\"http:\/\/www.86duino.com\/?p=3076\" target=\"_blank\" rel=\"noopener\">[]<\/a>&nbsp;(element access)<\/li><li>[Language]&nbsp;<a href=\"http:\/\/www.86duino.com\/?p=3078\" target=\"_blank\" rel=\"noopener\">+&nbsp;<\/a>(concatenation)<\/li><li>[Language]&nbsp;<a href=\"http:\/\/www.86duino.com\/?p=3080\" target=\"_blank\" rel=\"noopener\">==<\/a>&nbsp;(comparison)<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Example<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The following are examples of the&nbsp;<code>String<\/code>&nbsp;class from the&nbsp;<a href=\"http:\/\/arduino.cc\/en\/Tutorial\/HomePage\" target=\"_blank\" rel=\"noopener\">Arduino Tutorial<\/a>&nbsp;that can work on the 86Duino boards:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>[Language]&nbsp;<a href=\"http:\/\/arduino.cc\/en\/Tutorial\/StringConstructors\" target=\"_blank\" rel=\"noopener\">StringConstructors<\/a><\/li><li>[Language]&nbsp;<a href=\"http:\/\/arduino.cc\/en\/Tutorial\/StringAdditionOperator\" target=\"_blank\" rel=\"noopener\">StringAdditionOperator<\/a><\/li><li>[Language]&nbsp;<a href=\"http:\/\/arduino.cc\/en\/Tutorial\/StringIndexOf\" target=\"_blank\" rel=\"noopener\">StringIndexOf<\/a><\/li><li>[Language]&nbsp;<a href=\"http:\/\/arduino.cc\/en\/Tutorial\/StringAppendOperator\" target=\"_blank\" rel=\"noopener\">StringAppendOperator<\/a><\/li><li>[Language]&nbsp;<a href=\"http:\/\/arduino.cc\/en\/Tutorial\/StringLengthTrim\" target=\"_blank\" rel=\"noopener\">StringLengthTrim<\/a><\/li><li>[Language]&nbsp;<a href=\"http:\/\/arduino.cc\/en\/Tutorial\/StringCaseChanges\" target=\"_blank\" rel=\"noopener\">StringCaseChanges<\/a><\/li><li>[Language]&nbsp;<a href=\"http:\/\/arduino.cc\/en\/Tutorial\/StringReplace\" target=\"_blank\" rel=\"noopener\">StringReplace<\/a><\/li><li>[Language]&nbsp;<a href=\"http:\/\/arduino.cc\/en\/Tutorial\/StringCharacters\" target=\"_blank\" rel=\"noopener\">StringCharacters<\/a><\/li><li>[Language]&nbsp;<a href=\"http:\/\/arduino.cc\/en\/Tutorial\/StringStartsWithEndsWith\" target=\"_blank\" rel=\"noopener\">StringStartsWithEndsWith<\/a><\/li><li>[Language]&nbsp;<a href=\"http:\/\/arduino.cc\/en\/Tutorial\/StringComparisonOperators\" target=\"_blank\" rel=\"noopener\">StringComparisonOperators<\/a><\/li><li>[Language]&nbsp;<a href=\"http:\/\/arduino.cc\/en\/Tutorial\/StringSubstring\" target=\"_blank\" rel=\"noopener\">StringSubstring<\/a><\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">See also<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>[Language]&nbsp;<a href=\"https:\/\/www.qec.tw\/86duino-reference\/string\/\">string<\/a>: character arrays<\/li><li>[Language]&nbsp;<a href=\"http:\/\/www.86duino.com\/?p=2933\" target=\"_blank\" rel=\"noopener\">Variable Declaration<\/a><\/li><\/ul>\n\n\n<hr>\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/www.qec.tw\/86duino\/86duino-language-reference\/\">Language Reference Home<\/a><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><em>The text of the 86Duino reference is a modification of&nbsp;<a href=\"http:\/\/arduino.cc\/en\/Reference\/HomePage\" target=\"_blank\" rel=\"noopener\">the Arduino reference<\/a>&nbsp;and is licensed under a&nbsp;<a href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/3.0\/\" target=\"_blank\" rel=\"noopener\">Creative Commons Attribution-ShareAlike 3.0 License<\/a>. Code samples in the reference are released into the public domain.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[Data Types] Description The String class allows you to use and manipulate strings of text in more complex ways than&nbsp;character arrays&nbsp;do. You can concatenate Strings, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6841,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[195],"tags":[162],"class_list":["post-6840","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-86duino-reference","tag-86duino"],"_links":{"self":[{"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/posts\/6840","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/comments?post=6840"}],"version-history":[{"count":0,"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/posts\/6840\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/media\/6841"}],"wp:attachment":[{"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/media?parent=6840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/categories?post=6840"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/tags?post=6840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}