如何在.sxt文件中搜索Unityscript中的关键字?(How can I search a .txt file for a keyword in Unityscript?)
在.txt文件中搜索JavaScript中的关键字的正确语法是什么?
编辑:我在一个名为Unity3D的程序中使用了一个名为UnityScript的JavaScript子集。 它输出.exe程序。 这是UnityScript的一个例子:
import System.IO; function ReadFile () { var sr = new StreamReader(Application.dataPath + "/" + readFilePath); var fileContents = sr.ReadToEnd(); sr.Close(); var lines = fileContents.Split("~"[0]); for (line in lines) { Debug.Log (line); } }
我想如果我能从JavaScript获得一个函数,我可以将它导入我的程序。 我现在看到也许我错了。
谢谢 - Elliot Bonneville
What's the correct syntax to search a .txt file for a keyword in JavaScript?
EDIT: I'm working with a subset of JavaScript called UnityScript in a program called Unity3D. It outputs .exe programs. Here's an example of UnityScript:
import System.IO; function ReadFile () { var sr = new StreamReader(Application.dataPath + "/" + readFilePath); var fileContents = sr.ReadToEnd(); sr.Close(); var lines = fileContents.Split("~"[0]); for (line in lines) { Debug.Log (line); } }
I thought that if I could get a function from JavaScript I could import it into my program. I see now that perhaps I was wrong.
Thanks - Elliot Bonneville
原文:https://stackoverflow.com/questions/3358737
最满意答案
根据“SQLite数据库文件格式” ,每个SQLite文件都以字节“SQLite format 3”开头,然后是nul终止。
假设加密加密文件的所有字节,您可以读取前16个字节并检查它们是否与上面的字符串匹配。
但更简单的方法是使用
sqlite3_open()
或其中一个相关的open调用打开文件。 如果失败并显示错误代码SQLITE_CORRUPT
,则可以假定该文件已加密,因此您将其解密并再次打开。According to "The SQLite Database File Format", every SQLite file starts with the bytes "SQLite format 3", followed by a nul termination.
Assuming that the encryption scrambles all bytes of the file, you can read the first 16 bytes and check if they match the above string.
But a simpler method is to just open the file with
sqlite3_open()
or one of the related open calls. If that fails with the error codeSQLITE_CORRUPT
, you can assume that the file was encrypted, so you decrypt it and open it again.
相关问答
更多-
正如Jacob所说,你必须在UITextView上运行becomeFirstResponder ,使其成为第一个响应者,即用户当前使用的对象。 如果你这样做,iPhone OS自动显示键盘,这是从用户的角度来看用UITextView工作所需要的。 As Jacob said, you'll have to run becomeFirstResponder on a UITextView to make it the first responder, the object the user's current ...
-
我没有任何证据表明这一点,但这将涉及修改“用户体验” - 这是苹果永远不会允许的 (为什么仍有很多人越狱他们的手机)。 这涉及到“关机”以及“静音” - 因为两者都可能破坏用户体验(您需要等待重要的电话,但应用程序X打破了声音)。 I don't have any evidence for that, but this would involve modifying the "UserExperience" - which is something that Apple never would allow ...
-
首先,虽然可以强制杀死您的应用程序,但苹果不允许这样做,并且将被拒绝。 即使没有被拒绝,一旦它被杀死就无法重启你的应用程序。 您只需要找到一些方法来重置您的应用程序,通过代码,如Jason Coco说。 这可能是更多的工作,但值得不要被苹果拒绝。 First of all, although it is possible to force kill your app, this is not allowed by Apple and will rejected. Even if it wasn't reje ...
-
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); (在AudioServices.h中声明) AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); (Declared in AudioServices.h)
-
在玩之前,不可能识别。 当不正确的文件格式传递给它时,电影播放器会发生错误。 为此,首先必须注意以下消息: MPMoviePlayerLoadStateDidChangeNotification : [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerLoadStateChanged:) name:MPMoviePlayerLoadStateDidChangeNotification obj ...
-
我不相信有,反正当前的SDK没有。 您只能使用UIApplication的openURL:方法在Messages应用程序中预填充SMS消息。 I don't believe there is, not with the current SDK anyways. You can only prefill SMS messages in the Messages app using UIApplication's openURL: method.
-
你可以综合按钮的坐标,并在这里设置合适的事件 You could synthesize a touch on the button's coordinates, and set the appropriate event here's how
-
如何以编程方式了解任何文件是否加密? - iPhone(how to know programmatically any file is encrypted or not ?- iPhone)[2024-02-27]
根据“SQLite数据库文件格式” ,每个SQLite文件都以字节“SQLite format 3”开头,然后是nul终止。 假设加密加密文件的所有字节,您可以读取前16个字节并检查它们是否与上面的字符串匹配。 但更简单的方法是使用sqlite3_open()或其中一个相关的open调用打开文件。 如果失败并显示错误代码SQLITE_CORRUPT ,则可以假定该文件已加密,因此您将其解密并再次打开。 According to "The SQLite Database File Format", every ... -
您正在寻找MFMessageComposeController 。 要发送短信,你会看到这样的事情: #import
@interface myClass : NSObject { } @end @implementation -(void)sendMessage{ if([MFMessageComposeController canSendText]){ ... -
您需要的一般部分是: 用于访问手机联系人的“ 联系人”框架。 ContactsUI框架使用内置视图控制器来访问联系人。 使用CNContactVCardSerialization.dataWithContacts将CNContact数据编码为VCard格式。 使用data.writeToURL将数据写入文件。 使用NSURLSession将数据上载到服务器。 下面是一个示例,它回答了将联系人保存为VCard格式的问题。 import Contacts // Creating a mutable objec ...