팁 : GML 또는 다른 언어 용어를 검색 ,이 질문들은 여러 번 대답했다. 또한 언어 태그가 아닌 IDE 태그이므로 태그를 확인하십시오.
임 GML 자신에 대해 잘 알고 있지만, 빠른 검색이 나타났다하지 : 정확히 이것에 대한
적어도 반 공식적인 방법 : http://www.gmlscripts.com/script/bytes_to_bin
/// bytes_to_bin(str)
//
// Returns a string of binary digits, 1 bit each.
//
// str raw bytes, 8 bits each, string
//
/// GMLscripts.com/license
{
var str, bin, p, byte;
str = argument0;
bin = "";
p = string_length(str);
repeat (p) {
byte = ord(string_char_at(str,p));
repeat (8) {
if (byte & 1) bin = "1" + bin else bin = "0" + bin;
byte = byte >> 1;
}
p -= 1;
}
return bin;
}
GML 포럼 (가 몇 가지 예) https://www.reddit.com/r/gamemaker/comments/4opzhu/how_could_i_convert_a_string_to_binary/
을
///string_to_binary(string)
var str = argument0;
var output = "";
for(var i = 0; i < string_length(str); i++){
if(string_char_at(str, i + 1) == "0"){
output += "0";
}
else{
output += "1";
}
}
return real(output);
그리고 다른 언어 예 :
C++ Fastest way to Convert String to Binary?
#include <string>
#include <bitset>
#include <iostream>
using namespace std;
int main(){
string myString = "Hello World";
for (std::size_t i = 0; i < myString.size(); ++i)
{
cout << bitset<8>(myString.c_str()[i]) << endl;
}
}
자바 : Convert A String (like testing123) To Binary In Java
String s = "foo";
byte[] bytes = s.getBytes();
StringBuilder binary = new StringBuilder();
for (byte b : bytes)
{
int val = b;
for (int i = 0; i < 8; i++)
{
binary.append((val & 128) == 0 ? 0 : 1);
val <<= 1;
}
binary.append(' ');
}
System.out.println("'" + s + "' to binary: " + binary);
JS : How to convert text to binary code in JavaScript?
function convert() {
var output = document.getElementById("ti2");
var input = document.getElementById("ti1").value;
output.value = "";
for (var i = 0; i < input.length; i++) {
output.value += input[i].charCodeAt(0).toString(2) + " ";
}
}
업데이트 당신이하시기 바랍니다 사용하는 실제 언어를 포함하는 귀하의 질문에, 위선적 인 말투는 정말로 당신을 다르게 도와줍니다. 미래에 다른 사람들을 쉽게 검색 할 수 있습니다. http://stackoverflow.com/help/how-to-ask –
string_char_at() 대신에 원하는 함수는 string_ord_at()입니다. - 그 자리에서 문자의 숫자 값을 가져옵니다. 그런 다음이 숫자 값을 바이너리로 변환해야합니다. 아래 답변의 Java 예제는 게임 제작자가 가지고 있지 않은 내장 데이터 유형과 함수에 의존하기 때문에 아마도 세 가지 중에서 가장 유용 할 것입니다. –
@DanielBrose Game Maker 언어 __IS__ 언어 https://docs.yoyogames.com/source/dadiospice/002_reference/ –