String.xml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="String" category="Built-In Types" version="3.0.alpha.custom_build">
  3. <brief_description>
  4. Built-in string class.
  5. </brief_description>
  6. <description>
  7. This is the built-in string class (and the one used by GDScript). It supports Unicode and provides all necessary means for string handling. Strings are reference counted and use a copy-on-write approach, so passing them around is cheap in resources.
  8. </description>
  9. <tutorials>
  10. </tutorials>
  11. <demos>
  12. </demos>
  13. <methods>
  14. <method name="String">
  15. <return type="String">
  16. </return>
  17. <argument index="0" name="from" type="bool">
  18. </argument>
  19. <description>
  20. Constructs a new String from the given [bool].
  21. </description>
  22. </method>
  23. <method name="String">
  24. <return type="String">
  25. </return>
  26. <argument index="0" name="from" type="int">
  27. </argument>
  28. <description>
  29. Constructs a new String from the given [int].
  30. </description>
  31. </method>
  32. <method name="String">
  33. <return type="String">
  34. </return>
  35. <argument index="0" name="from" type="float">
  36. </argument>
  37. <description>
  38. Constructs a new String from the given [float].
  39. </description>
  40. </method>
  41. <method name="String">
  42. <return type="String">
  43. </return>
  44. <argument index="0" name="from" type="Vector2">
  45. </argument>
  46. <description>
  47. Constructs a new String from the given [Vector2].
  48. </description>
  49. </method>
  50. <method name="String">
  51. <return type="String">
  52. </return>
  53. <argument index="0" name="from" type="Rect2">
  54. </argument>
  55. <description>
  56. Constructs a new String from the given [Rect2].
  57. </description>
  58. </method>
  59. <method name="String">
  60. <return type="String">
  61. </return>
  62. <argument index="0" name="from" type="Vector3">
  63. </argument>
  64. <description>
  65. Constructs a new String from the given [Vector3].
  66. </description>
  67. </method>
  68. <method name="String">
  69. <return type="String">
  70. </return>
  71. <argument index="0" name="from" type="Transform2D">
  72. </argument>
  73. <description>
  74. Constructs a new String from the given [Transform2D].
  75. </description>
  76. </method>
  77. <method name="String">
  78. <return type="String">
  79. </return>
  80. <argument index="0" name="from" type="Plane">
  81. </argument>
  82. <description>
  83. Constructs a new String from the given [Plane].
  84. </description>
  85. </method>
  86. <method name="String">
  87. <return type="String">
  88. </return>
  89. <argument index="0" name="from" type="Quat">
  90. </argument>
  91. <description>
  92. Constructs a new String from the given [Quat].
  93. </description>
  94. </method>
  95. <method name="String">
  96. <return type="String">
  97. </return>
  98. <argument index="0" name="from" type="Rect3">
  99. </argument>
  100. <description>
  101. Constructs a new String from the given [Rect3].
  102. </description>
  103. </method>
  104. <method name="String">
  105. <return type="String">
  106. </return>
  107. <argument index="0" name="from" type="Basis">
  108. </argument>
  109. <description>
  110. Constructs a new String from the given [Basis].
  111. </description>
  112. </method>
  113. <method name="String">
  114. <return type="String">
  115. </return>
  116. <argument index="0" name="from" type="Transform">
  117. </argument>
  118. <description>
  119. Constructs a new String from the given [Transform].
  120. </description>
  121. </method>
  122. <method name="String">
  123. <return type="String">
  124. </return>
  125. <argument index="0" name="from" type="Color">
  126. </argument>
  127. <description>
  128. Constructs a new String from the given [Color].
  129. </description>
  130. </method>
  131. <method name="String">
  132. <return type="String">
  133. </return>
  134. <argument index="0" name="from" type="NodePath">
  135. </argument>
  136. <description>
  137. Constructs a new String from the given [NodePath].
  138. </description>
  139. </method>
  140. <method name="String">
  141. <return type="String">
  142. </return>
  143. <argument index="0" name="from" type="RID">
  144. </argument>
  145. <description>
  146. Constructs a new String from the given [RID].
  147. </description>
  148. </method>
  149. <method name="String">
  150. <return type="String">
  151. </return>
  152. <argument index="0" name="from" type="Dictionary">
  153. </argument>
  154. <description>
  155. Constructs a new String from the given [Dictionary].
  156. </description>
  157. </method>
  158. <method name="String">
  159. <return type="String">
  160. </return>
  161. <argument index="0" name="from" type="Array">
  162. </argument>
  163. <description>
  164. Constructs a new String from the given [Array].
  165. </description>
  166. </method>
  167. <method name="String">
  168. <return type="String">
  169. </return>
  170. <argument index="0" name="from" type="PoolByteArray">
  171. </argument>
  172. <description>
  173. Constructs a new String from the given [PoolByteArray].
  174. </description>
  175. </method>
  176. <method name="String">
  177. <return type="String">
  178. </return>
  179. <argument index="0" name="from" type="PoolIntArray">
  180. </argument>
  181. <description>
  182. Constructs a new String from the given [PoolIntArray].
  183. </description>
  184. </method>
  185. <method name="String">
  186. <return type="String">
  187. </return>
  188. <argument index="0" name="from" type="PoolRealArray">
  189. </argument>
  190. <description>
  191. Constructs a new String from the given [PoolRealArray].
  192. </description>
  193. </method>
  194. <method name="String">
  195. <return type="String">
  196. </return>
  197. <argument index="0" name="from" type="PoolStringArray">
  198. </argument>
  199. <description>
  200. Constructs a new String from the given [PoolStringArray].
  201. </description>
  202. </method>
  203. <method name="String">
  204. <return type="String">
  205. </return>
  206. <argument index="0" name="from" type="PoolVector2Array">
  207. </argument>
  208. <description>
  209. Constructs a new String from the given [PoolVector2Array].
  210. </description>
  211. </method>
  212. <method name="String">
  213. <return type="String">
  214. </return>
  215. <argument index="0" name="from" type="PoolVector3Array">
  216. </argument>
  217. <description>
  218. Constructs a new String from the given [PoolVector3Array].
  219. </description>
  220. </method>
  221. <method name="String">
  222. <return type="String">
  223. </return>
  224. <argument index="0" name="from" type="PoolColorArray">
  225. </argument>
  226. <description>
  227. Constructs a new String from the given [PoolColorArray].
  228. </description>
  229. </method>
  230. <method name="begins_with">
  231. <return type="bool">
  232. </return>
  233. <argument index="0" name="text" type="String">
  234. </argument>
  235. <description>
  236. Returns [code]true[/code] if the string begins with the given string.
  237. </description>
  238. </method>
  239. <method name="bigrams">
  240. <return type="PoolStringArray">
  241. </return>
  242. <description>
  243. Returns the bigrams (pairs of consecutive letters) of this string.
  244. </description>
  245. </method>
  246. <method name="c_escape">
  247. <return type="String">
  248. </return>
  249. <description>
  250. Returns a copy of the string with special characters escaped using the C language standard.
  251. </description>
  252. </method>
  253. <method name="c_unescape">
  254. <return type="String">
  255. </return>
  256. <description>
  257. Returns a copy of the string with escaped characters replaced by their meanings according to the C language standard.
  258. </description>
  259. </method>
  260. <method name="capitalize">
  261. <return type="String">
  262. </return>
  263. <description>
  264. Changes the case of some letters. Replaces underscores with spaces, converts all letters to lowercase, then capitalizes first and every letter following the space character. For [code]capitalize camelCase mixed_with_underscores[/code] it will return [code]Capitalize Camelcase Mixed With Underscores[/code].
  265. </description>
  266. </method>
  267. <method name="casecmp_to">
  268. <return type="int">
  269. </return>
  270. <argument index="0" name="to" type="String">
  271. </argument>
  272. <description>
  273. Performs a case-sensitive comparison to another string. Returns [code]-1[/code] if less than, [code]+1[/code] if greater than, or [code]0[/code] if equal.
  274. </description>
  275. </method>
  276. <method name="empty">
  277. <return type="bool">
  278. </return>
  279. <description>
  280. Returns [code]true[/code] if the string is empty.
  281. </description>
  282. </method>
  283. <method name="ends_with">
  284. <return type="bool">
  285. </return>
  286. <argument index="0" name="text" type="String">
  287. </argument>
  288. <description>
  289. Returns [code]true[/code] if the string ends with the given string.
  290. </description>
  291. </method>
  292. <method name="erase">
  293. <argument index="0" name="position" type="int">
  294. </argument>
  295. <argument index="1" name="chars" type="int">
  296. </argument>
  297. <description>
  298. Erases [code]chars[/code] characters from the string starting from [code]position[/code].
  299. </description>
  300. </method>
  301. <method name="find">
  302. <return type="int">
  303. </return>
  304. <argument index="0" name="what" type="String">
  305. </argument>
  306. <argument index="1" name="from" type="int" default="0">
  307. </argument>
  308. <description>
  309. Finds the first occurrence of a substring. Returns the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed.
  310. </description>
  311. </method>
  312. <method name="find_last">
  313. <return type="int">
  314. </return>
  315. <argument index="0" name="what" type="String">
  316. </argument>
  317. <description>
  318. Finds the last occurrence of a substring. Returns the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed.
  319. </description>
  320. </method>
  321. <method name="findn">
  322. <return type="int">
  323. </return>
  324. <argument index="0" name="what" type="String">
  325. </argument>
  326. <argument index="1" name="from" type="int" default="0">
  327. </argument>
  328. <description>
  329. Finds the first occurrence of a substring, ignoring case. Returns the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed.
  330. </description>
  331. </method>
  332. <method name="format">
  333. <return type="String">
  334. </return>
  335. <argument index="0" name="values" type="var">
  336. </argument>
  337. <argument index="1" name="placeholder" type="String" default="{_}">
  338. </argument>
  339. <description>
  340. Formats the string by replacing all occurences of [code]placeholder[/code] with [code]values[/code].
  341. </description>
  342. </method>
  343. <method name="get_base_dir">
  344. <return type="String">
  345. </return>
  346. <description>
  347. If the string is a valid file path, returns the base directory name.
  348. </description>
  349. </method>
  350. <method name="get_basename">
  351. <return type="String">
  352. </return>
  353. <description>
  354. If the string is a valid file path, returns the full file path without the extension.
  355. </description>
  356. </method>
  357. <method name="get_extension">
  358. <return type="String">
  359. </return>
  360. <description>
  361. If the string is a valid file path, returns the extension.
  362. </description>
  363. </method>
  364. <method name="get_file">
  365. <return type="String">
  366. </return>
  367. <description>
  368. If the string is a valid file path, returns the filename.
  369. </description>
  370. </method>
  371. <method name="hash">
  372. <return type="int">
  373. </return>
  374. <description>
  375. Hashes the string and returns a 32-bit integer.
  376. </description>
  377. </method>
  378. <method name="hex_to_int">
  379. <return type="int">
  380. </return>
  381. <description>
  382. Converts a string containing a hexadecimal number into an integer.
  383. </description>
  384. </method>
  385. <method name="insert">
  386. <return type="String">
  387. </return>
  388. <argument index="0" name="position" type="int">
  389. </argument>
  390. <argument index="1" name="what" type="String">
  391. </argument>
  392. <description>
  393. Inserts a substring at a given position.
  394. </description>
  395. </method>
  396. <method name="is_abs_path">
  397. <return type="bool">
  398. </return>
  399. <description>
  400. If the string is a path to a file or directory, returns [code]true[/code] if the path is absolute.
  401. </description>
  402. </method>
  403. <method name="is_rel_path">
  404. <return type="bool">
  405. </return>
  406. <description>
  407. If the string is a path to a file or directory, returns [code]true[/code] if the path is relative.
  408. </description>
  409. </method>
  410. <method name="is_subsequence_of">
  411. <return type="bool">
  412. </return>
  413. <argument index="0" name="text" type="String">
  414. </argument>
  415. <description>
  416. Returns [code]true[/code] if this string is a subsequence of the given string.
  417. </description>
  418. </method>
  419. <method name="is_subsequence_ofi">
  420. <return type="bool">
  421. </return>
  422. <argument index="0" name="text" type="String">
  423. </argument>
  424. <description>
  425. Returns [code]true[/code] if this string is a subsequence of the given string, without considering case.
  426. </description>
  427. </method>
  428. <method name="is_valid_float">
  429. <return type="bool">
  430. </return>
  431. <description>
  432. Returns [code]true[/code] if this string contains a valid float.
  433. </description>
  434. </method>
  435. <method name="is_valid_html_color">
  436. <return type="bool">
  437. </return>
  438. <description>
  439. Returns [code]true[/code] if this string contains a valid color in HTML notation.
  440. </description>
  441. </method>
  442. <method name="is_valid_identifier">
  443. <return type="bool">
  444. </return>
  445. <description>
  446. Returns [code]true[/code] if this string is a valid identifier. A valid identifier may contain only letters, digits and underscores (_) and the first character may not be a digit.
  447. </description>
  448. </method>
  449. <method name="is_valid_integer">
  450. <return type="bool">
  451. </return>
  452. <description>
  453. Returns [code]true[/code] if this string contains a valid integer.
  454. </description>
  455. </method>
  456. <method name="is_valid_ip_address">
  457. <return type="bool">
  458. </return>
  459. <description>
  460. Returns [code]true[/code] if this string contains a valid IP address.
  461. </description>
  462. </method>
  463. <method name="json_escape">
  464. <return type="String">
  465. </return>
  466. <description>
  467. Returns a copy of the string with special characters escaped using the JSON standard.
  468. </description>
  469. </method>
  470. <method name="left">
  471. <return type="String">
  472. </return>
  473. <argument index="0" name="position" type="int">
  474. </argument>
  475. <description>
  476. Returns a number of characters from the left of the string.
  477. </description>
  478. </method>
  479. <method name="length">
  480. <return type="int">
  481. </return>
  482. <description>
  483. Returns the string's amount of characters.
  484. </description>
  485. </method>
  486. <method name="match">
  487. <return type="bool">
  488. </return>
  489. <argument index="0" name="expr" type="String">
  490. </argument>
  491. <description>
  492. Does a simple expression match, where '*' matches zero or more arbitrary characters and '?' matches any single character except '.'.
  493. </description>
  494. </method>
  495. <method name="matchn">
  496. <return type="bool">
  497. </return>
  498. <argument index="0" name="expr" type="String">
  499. </argument>
  500. <description>
  501. Does a simple case insensitive expression match, using ? and * wildcards (see [method match]).
  502. </description>
  503. </method>
  504. <method name="md5_buffer">
  505. <return type="PoolByteArray">
  506. </return>
  507. <description>
  508. Returns the MD5 hash of the string as an array of bytes.
  509. </description>
  510. </method>
  511. <method name="md5_text">
  512. <return type="String">
  513. </return>
  514. <description>
  515. Returns the MD5 hash of the string as a string.
  516. </description>
  517. </method>
  518. <method name="nocasecmp_to">
  519. <return type="int">
  520. </return>
  521. <argument index="0" name="to" type="String">
  522. </argument>
  523. <description>
  524. Performs a case-insensitive comparison to another string. Returns [code]-1[/code] if less than, [code]+1[/code] if greater than, or [code]0[/code] if equal.
  525. </description>
  526. </method>
  527. <method name="ord_at">
  528. <return type="int">
  529. </return>
  530. <argument index="0" name="at" type="int">
  531. </argument>
  532. <description>
  533. Returns the character code at position [code]at[/code].
  534. </description>
  535. </method>
  536. <method name="pad_decimals">
  537. <return type="String">
  538. </return>
  539. <argument index="0" name="digits" type="int">
  540. </argument>
  541. <description>
  542. Formats a number to have an exact number of [code]digits[/code] after the decimal point.
  543. </description>
  544. </method>
  545. <method name="pad_zeros">
  546. <return type="String">
  547. </return>
  548. <argument index="0" name="digits" type="int">
  549. </argument>
  550. <description>
  551. Formats a number to have an exact number of [code]digits[/code] before the decimal point.
  552. </description>
  553. </method>
  554. <method name="percent_decode">
  555. <return type="String">
  556. </return>
  557. <description>
  558. Decode a percent-encoded string. See [method percent_encode].
  559. </description>
  560. </method>
  561. <method name="percent_encode">
  562. <return type="String">
  563. </return>
  564. <description>
  565. Percent-encodes a string. Encodes parameters in a URL when sending a HTTP GET request (and bodies of form-urlencoded POST requests).
  566. </description>
  567. </method>
  568. <method name="plus_file">
  569. <return type="String">
  570. </return>
  571. <argument index="0" name="file" type="String">
  572. </argument>
  573. <description>
  574. If the string is a path, this concatenates [code]file[/code] at the end of the string as a subpath. E.g. [code]"this/is".plus_file("path") == "this/is/path"[/code].
  575. </description>
  576. </method>
  577. <method name="replace">
  578. <return type="String">
  579. </return>
  580. <argument index="0" name="what" type="String">
  581. </argument>
  582. <argument index="1" name="forwhat" type="String">
  583. </argument>
  584. <description>
  585. Replaces occurrences of a substring with the given one inside the string.
  586. </description>
  587. </method>
  588. <method name="replacen">
  589. <return type="String">
  590. </return>
  591. <argument index="0" name="what" type="String">
  592. </argument>
  593. <argument index="1" name="forwhat" type="String">
  594. </argument>
  595. <description>
  596. Replaces occurrences of a substring with the given one inside the string. Ignores case.
  597. </description>
  598. </method>
  599. <method name="rfind">
  600. <return type="int">
  601. </return>
  602. <argument index="0" name="what" type="String">
  603. </argument>
  604. <argument index="1" name="from" type="int" default="-1">
  605. </argument>
  606. <description>
  607. Performs a search for a substring, but starts from the end of the string instead of the beginning.
  608. </description>
  609. </method>
  610. <method name="rfindn">
  611. <return type="int">
  612. </return>
  613. <argument index="0" name="what" type="String">
  614. </argument>
  615. <argument index="1" name="from" type="int" default="-1">
  616. </argument>
  617. <description>
  618. Performs a search for a substring, but starts from the end of the string instead of the beginning. Ignores case.
  619. </description>
  620. </method>
  621. <method name="right">
  622. <return type="String">
  623. </return>
  624. <argument index="0" name="position" type="int">
  625. </argument>
  626. <description>
  627. Returns the right side of the string from a given position.
  628. </description>
  629. </method>
  630. <method name="sha256_buffer">
  631. <return type="PoolByteArray">
  632. </return>
  633. <description>
  634. </description>
  635. </method>
  636. <method name="sha256_text">
  637. <return type="String">
  638. </return>
  639. <description>
  640. Returns the SHA-256 hash of the string as a string.
  641. </description>
  642. </method>
  643. <method name="similarity">
  644. <return type="float">
  645. </return>
  646. <argument index="0" name="text" type="String">
  647. </argument>
  648. <description>
  649. Returns the similarity index of the text compared to this string. 1 means totally similar and 0 means totally dissimilar.
  650. </description>
  651. </method>
  652. <method name="split">
  653. <return type="PoolStringArray">
  654. </return>
  655. <argument index="0" name="divisor" type="String">
  656. </argument>
  657. <argument index="1" name="allow_empty" type="bool" default="True">
  658. </argument>
  659. <description>
  660. Splits the string by a divisor string and returns an array of the substrings. Example "One,Two,Three" will return ["One","Two","Three"] if split by ",".
  661. </description>
  662. </method>
  663. <method name="split_floats">
  664. <return type="PoolRealArray">
  665. </return>
  666. <argument index="0" name="divisor" type="String">
  667. </argument>
  668. <argument index="1" name="allow_empty" type="bool" default="True">
  669. </argument>
  670. <description>
  671. Splits the string in floats by using a divisor string and returns an array of the substrings. Example "1,2.5,3" will return [1,2.5,3] if split by ",".
  672. </description>
  673. </method>
  674. <method name="strip_edges">
  675. <return type="String">
  676. </return>
  677. <argument index="0" name="left" type="bool" default="True">
  678. </argument>
  679. <argument index="1" name="right" type="bool" default="True">
  680. </argument>
  681. <description>
  682. Returns a copy of the string stripped of any non-printable character at the beginning and the end. The optional arguments are used to toggle stripping on the left and right edges respectively.
  683. </description>
  684. </method>
  685. <method name="substr">
  686. <return type="String">
  687. </return>
  688. <argument index="0" name="from" type="int">
  689. </argument>
  690. <argument index="1" name="len" type="int">
  691. </argument>
  692. <description>
  693. Returns part of the string from the position [code]from[/code] with length [code]len[/code].
  694. </description>
  695. </method>
  696. <method name="to_ascii">
  697. <return type="PoolByteArray">
  698. </return>
  699. <description>
  700. Converts the String (which is a character array) to [PoolByteArray] (which is an array of bytes). The conversion is sped up in comparison to to_utf8() with the assumption that all the characters the String contains are only ASCII characters.
  701. </description>
  702. </method>
  703. <method name="to_float">
  704. <return type="float">
  705. </return>
  706. <description>
  707. Converts a string containing a decimal number into a [code]float[/code].
  708. </description>
  709. </method>
  710. <method name="to_int">
  711. <return type="int">
  712. </return>
  713. <description>
  714. Converts a string containing an integer number into an [code]int[/code].
  715. </description>
  716. </method>
  717. <method name="to_lower">
  718. <return type="String">
  719. </return>
  720. <description>
  721. Returns the string converted to lowercase.
  722. </description>
  723. </method>
  724. <method name="to_upper">
  725. <return type="String">
  726. </return>
  727. <description>
  728. Returns the string converted to uppercase.
  729. </description>
  730. </method>
  731. <method name="to_utf8">
  732. <return type="PoolByteArray">
  733. </return>
  734. <description>
  735. Converts the String (which is an array of characters) to [PoolByteArray] (which is an array of bytes). The conversion is a bit slower than to_ascii(), but supports all UTF-8 characters. Therefore, you should prefer this function over to_ascii().
  736. </description>
  737. </method>
  738. <method name="xml_escape">
  739. <return type="String">
  740. </return>
  741. <description>
  742. Returns a copy of the string with special characters escaped using the XML standard.
  743. </description>
  744. </method>
  745. <method name="xml_unescape">
  746. <return type="String">
  747. </return>
  748. <description>
  749. Returns a copy of the string with escaped characters replaced by their meanings according to the XML standard.
  750. </description>
  751. </method>
  752. </methods>
  753. <constants>
  754. </constants>
  755. </class>